If I have the following program:
struct Foo {
a: usize,
b: usize,
}
struct Bar(Foo);
fn unwrap_bars(bars: Vec<Bar>) -> Vec<Foo> {
bars.into_iter().map(|b| b.0).collect()
}
Will unwrap_bars be compiled to an identity function? If it is not compiled to an identity function then how could I write unwrap_bars so that I keep the newtype abstraction while allowing free unwrapping of a collection of Bars?
I assume that a newtype wrapper like Bar compiles directly to Foo without adding any extra memory indirection.