pub fn new_clones<T>(len: usize, val: T) -> Box<[T]> where
T: Clone,
Creates a boxed slice of len
clones of val
.
#[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,
Bread::Wheat,
])
);