Guest User

Untitled

a guest
Jul 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. fn main() {
  2. println!("Hello, world!");
  3. Foo::new(Baz("borrow")).run();
  4. }
  5.  
  6. struct Baz<'a>(&'a str);
  7.  
  8. struct Foo<'a> {
  9. baz: Baz<'a>,
  10. }
  11.  
  12. impl<'a> Foo<'a> {
  13. fn new(baz: Baz<'a>) -> Foo<'a> {
  14. Self {
  15. baz,
  16. }
  17. }
  18. fn run(&mut self) {
  19. Qux {
  20. mut_baz: &mut self.baz,
  21. };
  22. }
  23. }
  24.  
  25. struct Qux<'a> {
  26. mut_baz: &'a mut Baz<'a>,
  27. }
Add Comment
Please, Sign In to add comment