// *** before: ***
// an associated type could not have parameters of its own,
// so a lending trait could not be written at all
trait Container {
type Item;
fn get(&self) -> Self::Item; // by value only
}
// *** in version 1.65: ***
trait Container {
type Item<'a> where Self: 'a;
fn get<'a>(&'a self) ->
Self::Item<'a>; // a reference inside itself is fine
}
impl Container for Vec<String> {
type Item<'a> = &'a str;
fn get<'a>(&'a self) -> &'a str {
&self[0]
}
}