Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- println!("Hello, world!");
- Foo::new(Baz("borrow")).run();
- }
- struct Baz<'a>(&'a str);
- struct Foo<'a> {
- baz: Baz<'a>,
- }
- impl<'a> Foo<'a> {
- fn new(baz: Baz<'a>) -> Foo<'a> {
- Self {
- baz,
- bar: "a".to_string(),
- }
- }
- fn run(&mut self) {
- Qux {
- mut_baz: &mut self.baz,
- };
- }
- }
- struct Qux<'a> {
- mut_baz: &'a mut Baz<'a>,
- }
Add Comment
Please, Sign In to add comment