Created
April 26, 2016 01:50
-
-
Save Sgeo/6b823374aa48295f11e83e1bba65dcfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ApplyLTable<'to> { | |
type Applied; | |
} | |
impl<'from, 'to, T: 'from+'to> ApplyLTable<'to> for &'from T { | |
type Applied = &'to T; | |
} | |
impl<'from, 'to, T: 'from+'to> ApplyLTable<'to> for &'from mut T { | |
type Applied = &'to mut T; | |
} | |
type ApplyLT<'lt, T> = <T as ApplyLTable<'lt>>::Applied; | |
trait Streamer { | |
type Item: for<'a> ApplyLTable<'a>; | |
fn next<'a>(&'a mut self) -> Option<ApplyLT<'a, Self::Item>>; | |
} | |
struct SelfStreaming; | |
impl Streamer for SelfStreaming { | |
type Item = &'static mut Self; | |
fn next<'a>(&'a mut self) -> Option<&'a mut Self> { | |
Some(self) | |
} | |
} | |
fn main() { | |
let mut foo = SelfStreaming; | |
foo.next(); | |
foo.next(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment