Closed
Description
The following code compiles with Rust version 1.20, but not with 1.21 and above:
pub trait StreamingIterator<'a>: 'a {
type Item: 'a;
fn next(&'a mut self) -> Option<Self::Item>;
}
pub trait StreamingIteratorExt: for<'a> StreamingIterator<'a> {}
impl<I> StreamingIteratorExt for I where
I: for<'a>StreamingIterator<'a>
{}
Error in Rust 1.21+:
error[E0310]: the parameter type `I` may not live long enough
--> src/lib.rs:14:9
|
14 | impl<I> StreamingIteratorExt for I where
| - ^^^^^^^^^^^^^^^^^^^^
| |
| help: consider adding an explicit lifetime bound `I: 'static`...
|
note: ...so that the type `I` will meet its required lifetime bounds
--> src/lib.rs:14:9
|
14 | impl<I> StreamingIteratorExt for I where
| ^^^^^^^^^^^^^^^^^^^^
Note the Self: 'a
bound on StreamingIterator
. If I remove it, the error goes away.