[−][src]Function boxchop::new_with
pub fn new_with<T>(len: usize, gen: impl FnMut(usize) -> T) -> Box<[T]>
Creates a boxed slice of len
elements using the closure gen
to generate each element, given
the element's index.
Example
let nums = new_with(5, |x| x + 1); assert_eq!( nums, Box::from([1, 2, 3, 4, 5]) );