8 fn into_item(self) -> Self::Item;
9 fn as_item(&self) -> &Self::Item;
12 fn bad1<T: Iter>(v: T) -> Box<dyn X + 'static>
14 let item = v.into_item();
15 Box::new(item) //~ ERROR associated type `<T as Iter>::Item` may not live long enough
18 fn bad2<T: Iter>(v: T) -> Box<dyn X + 'static>
19 where Box<T::Item> : X
21 let item: Box<_> = Box::new(v.into_item());
22 Box::new(item) //~ ERROR associated type `<T as Iter>::Item` may not live long enough
25 fn bad3<'a, T: Iter>(v: T) -> Box<dyn X + 'a>
27 let item = v.into_item();
28 Box::new(item) //~ ERROR associated type `<T as Iter>::Item` may not live long enough
31 fn bad4<'a, T: Iter>(v: T) -> Box<dyn X + 'a>
32 where Box<T::Item> : X
34 let item: Box<_> = Box::new(v.into_item());
35 Box::new(item) //~ ERROR associated type `<T as Iter>::Item` may not live long enough
38 fn ok1<'a, T: Iter>(v: T) -> Box<dyn X + 'a>
41 let item = v.into_item();
42 Box::new(item) // OK, T::Item : 'a is declared
45 fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box<dyn X + 'a>
48 let item = Clone::clone(w);
49 Box::new(item) // OK, T::Item : 'a is implied
52 fn ok3<'a, T: Iter>(v: &'a T) -> Box<dyn X + 'a>
53 where T::Item : Clone + 'a
55 let item = Clone::clone(v.as_item());
56 Box::new(item) // OK, T::Item : 'a was declared
59 fn meh1<'a, T: Iter>(v: &'a T) -> Box<dyn X + 'a>
62 // This case is kind of interesting. It's the same as `ok3` but
63 // without the explicit declaration. This is valid because `T: 'a
64 // => T::Item: 'a`, and the former we can deduce from our argument
67 let item = Clone::clone(v.as_item());