0

In my case I am converting from Vec<u32> to Vec<usize>.

Currently doing:

let usize_vec:Vec<usize> = u32_vec.into_iter().map(|x|x as usize).collect();
trent
  • 21,712
  • 7
  • 47
  • 79
Jonathan Woollett-light
  • 2,093
  • 2
  • 22
  • 36

1 Answers1

0

That's the best way for your particular example, with u32 to usize. If you want to use unsafe features to transmute the contents of the vector instead, you can use std::slice::align_to/std::slice::align_to_mut.

apetranzilla
  • 4,419
  • 22
  • 30