[][src]Function rand_split::split_parts

pub fn split_parts<T>(
    cont: &[T],
    splits: &[f32]
) -> Result<Vec<Vec<T>>, &'static str> where
    T: Clone

Split the elements of a container in randomized sets which contain a a part (in splits) of the input.

Errors

Return an error if the parts in splits do not sum up to 1.

Example

use rand_split::split_parts;

println!("{:#?}", split_parts(&[1,2,3,4,5,6,8,9,10], &[0.4, 0.2, 0.4]));