How can I turn Vec into &[&str]?
By creating a new vector.
let vec = vec![String::from("abc")]; let slices: Vec<&str> = vec.iter().map(|s| s.as_str()).collect();
You can now borrow the new vector into a
&[&str]. The string slices in the new vector point into the old vector.
Why do you want to do this? This sounds like a xy problem.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.