[][src]Function boxchop::new_clones

pub fn new_clones<T>(len: usize, val: T) -> Box<[T]> where
    T: Clone

Creates a boxed slice of len clones of val.

Example

#[derive(Clone, Eq, PartialEq, Debug)]
enum Bread { Wheat, White, Other }

let loaf = new_clones(18, Bread::Wheat);

assert_eq!(
    loaf,
    Box::from([
        Bread::Wheat,
        Bread::Wheat,
        // ... 15 more
        Bread::Wheat,
    ])
);