Guest User

Untitled

a guest
Apr 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. trait Stream {
  2. type Output;
  3.  
  4. fn next(&self) -> Option<Self::Output>;
  5. }
  6.  
  7. struct Foo<'a, T: 'a>(&'a T);
  8.  
  9. impl<'a, T: 'a> Stream for Foo<'a, T> {
  10. type Output = &'a T;
  11.  
  12. fn next(&self) -> Option<Self::Output> {
  13. Some(&self.0)
  14. }
  15. }
  16.  
  17. fn main() {
  18. let i = 123;
  19. let foo = Foo(&i);
  20.  
  21. assert_eq!(foo.next(), Some(&123));
  22. }
Add Comment
Please, Sign In to add comment