There's no easy way, because &T
means it's borrowed, and T
means it's owned, and you can't take ownership of a thing you've borrowed — Rust doesn't support stealing!
The types are also physically laid out differently in memory, so there isn't even a way to cheat it. You'll have to copy all elements:
vec.into_iter().cloned().collect()