Guest User

Untitled

a guest
Jul 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 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. bar: "a".to_string(),
  17. }
  18. }
  19. fn run(&mut self) {
  20. Qux {
  21. mut_baz: &mut self.baz,
  22. };
  23. }
  24. }
  25.  
  26. struct Qux<'a> {
  27. mut_baz: &'a mut Baz<'a>,
  28. }
Add Comment
Please, Sign In to add comment