If I have a slice of structs &[Foo]
, and I've defined a newtype for Foo
called NewFoo
, is there a zero-cost way to convert &[Foo]
to &[NewFoo]
?
The best I've come up with is, which isn't zero-cost:
let _ = foos.iter().map(|foo| NewFoo(*foo)).collect::<Vec<NewFoo>>();