A flexible type for `Vec<String>`

I have used the IntoIterator also (here) to make a function accept a "list" of values, so I can either pass vec![x, y, z] or [x, y, z], etc.

I guess Into<String> can be used to denote any type that is convertible into a String (and might be the right choice here), but there is also ToString which has slightly different semantics, I believe.

See also Is there actually a semantic difference between FromStr and TryFrom<&str>? for a similar topic.


P.S.: Note that impl IntoIterator<Item = impl Into<String>> in argument position isn't really a type but a short syntax for making the function generic.

1 Like