Skip to content

Instantly share code, notes, and snippets.

@Sgeo
Created April 26, 2016 01:59
Show Gist options
  • Save Sgeo/8fd73763417fd03758a1e2812309d47a to your computer and use it in GitHub Desktop.
Save Sgeo/8fd73763417fd03758a1e2812309d47a to your computer and use it in GitHub Desktop.
trait Streamer<'a> {
type Item;
fn next(&'a mut self) -> Option<Self::Item>;
}
struct SelfStreaming;
impl<'a> Streamer<'a> for SelfStreaming {
type Item = &'a mut Self;
fn next(&'a mut self) -> Option<&'a mut Self> {
Some(self)
}
}
fn main() {
let mut foo = SelfStreaming;
let a = foo.next();
foo.next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment