Is it possible to write a function that accepts either Vec<String>
or Vec<&str>
without using an enum? I know that a scalar String
would automatically deref to a &str
, but it doesn't seem to be the case for strings inside a vector.
/// Replace variables in template with (potentially multiple) values
/// Results equal to the Cartesian product of variables interpolated
fn expand_vars<'a> (template : &[&'a str]) -> Vec<Vec<String>> {
...
}
The above signature works with let template = vec!["a", "b", "c"]
, but doesn't work with let template = vec!["a".to_owned(), "b".to_owned()]
(a Vec<String>
).