0

I have a function foo that takes x: &[&str]:

fn foo(x: &[&str]){}

And I want to pass y: Vec<String> to foo:

let y: Vec<String> = vec!["Foo".to_string()]
foo(&y)

But this raises an error:

mismatched types
expected slice, found struct `std::vec::Vec`

How can I do that?

tamuhey
  • 1,965
  • 1
  • 14
  • 33

0 Answers0