I can convert Vec
to Vec<&str>
this way:
let mut items = Vec::<&str>::new();
for item in &ano
The other answers simply work. I just want to point out that if you are trying to convert the Vec
into a Vec<&str>
only to pass it to a function taking Vec<&str>
as argument, consider revising the function signature as:
fn my_func>(list: &[T]) { ... }
instead of:
fn my_func(list: &Vec<&str>) { ... }
As pointed out by this question: Function taking both owned and non-owned string collections. In this way both vectors simply work without the need of conversions.