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
  • 25,033
  • 7
  • 51
  • 90
Jonathan Woollett-light
  • 2,813
  • 5
  • 30
  • 58

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
  • 5,331
  • 27
  • 34