pub fn split_by_count(
total: usize,
num_batches: usize,
) -> Result<Vec<NonZeroUsize>, String>Expand description
Splits a total number into a specified number of batches.
This function divides the total into the given number of batches, allowing for uneven distribution if necessary.
§Arguments
total- The total number to be split.num_batches- The number of batches to split the total into.
§Returns
A Result containing a vector of NonZeroUsize representing the size of each batch.
§Errors
Returns an error if:
- The total is zero.
- The number of batches is zero.
§Examples
use batch_maestro::split_by_count;
use std::num::NonZeroUsize;
let batch_sizes = split_by_count(10, 3).unwrap();
assert_eq!(batch_sizes, vec![NonZeroUsize::new(4).unwrap(), NonZeroUsize::new(3).unwrap(), NonZeroUsize::new(3).unwrap()]);