As I am poking at Rust, I was trying to write a Rust function that can take a look at anything iterable of strings.
My initial attempt was
fn example_1(iter: impl Iterator<Item=&str>);
fn example_2(iter: impl Iterator<Item=&String>);
// ...
that requires two functions for different cases.
I also tried combining cases above into one, and what I got is:
fn example_3<'a, T: 'a + ?Sized + Deref<str>>(iter: impl Iterator<Item=&'a T>);
that can accept both Iterator<Item=&String> and Iterator<Item=&str>, but not Iterator<String> (because last one requires one more borrow in the function body). Also, it looks way more complex than it probably should.
I of course can implement this using custom trait, maybe involving AsRef, but I think I might be missing a better and clearer way.