Page MenuHomePhabricator

[comm-lib] Add util to split vec into n chunks
ClosedPublic

Authored by bartek on Aug 21 2024, 1:31 AM.
Tags
None
Referenced Files
F3340903: D13129.id43537.diff
Thu, Nov 21, 10:13 PM
F3339664: D13129.id43568.diff
Thu, Nov 21, 8:28 PM
F3337250: D13129.diff
Thu, Nov 21, 4:18 PM
Unknown Object (File)
Fri, Nov 8, 7:03 PM
Unknown Object (File)
Fri, Nov 8, 7:03 PM
Unknown Object (File)
Fri, Nov 8, 7:01 PM
Unknown Object (File)
Fri, Oct 25, 2:37 AM
Unknown Object (File)
Wed, Oct 23, 10:12 AM
Subscribers

Details

Summary

The built-in vec.chunks(5) splits given collection into chunks of 5 items. Number of chunks is determined based on collection size.
However, there's no built-in utility for splitting collection into 5 chunks, where chunk sizes are determined based on collection size.

There are crates like itertools but it's an overkill to add a new dependency for such simple utility.
Created a simple trait that adds this functionality.

Test Plan

Unit tests

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage