Guest User

Untitled

a guest
Jan 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. struct Foo<'a> {
  2. bar: &'a i32
  3. }
  4.  
  5. /*impl<'a, 'b: 'a> Foo<'b> {
  6. fn new(bar: &'b i32) -> Self {
  7. Foo { bar }
  8. }
  9.  
  10. fn qux(&'a mut self) -> &'b i32 {
  11. self.bar
  12. }
  13. }*/
  14.  
  15. impl<'a> Foo<'a> {
  16. fn qux(&'a mut self) -> &'a i32 {
  17. self.bar
  18. }
  19. }
  20.  
  21. fn main() {
  22. let aaaaa = 0;
  23.  
  24. let mut f = Foo { bar: &aaaaa };
  25.  
  26. println!("{}", f.qux());
  27. println!("{}", f.qux());
  28. println!("{}", f.qux());
  29. println!("{}", f.qux());
  30. }
Add Comment
Please, Sign In to add comment