Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct A
- {
- b: B,
- }
- impl A
- {
- fn new() -> A
- {
- A
- {
- b: B::new(),
- }
- }
- fn foo(&mut self)
- {
- {
- let b = &mut self.b;
- b.foo();
- }
- self.baz();
- }
- fn baz(&self) -> String
- {
- String::from("Qux")
- }
- }
- #[derive(Debug)]
- struct B
- {
- b1: String,
- }
- impl B
- {
- fn new() -> B
- {
- B
- {
- b1: String::from(""),
- }
- }
- fn foo(&mut self)
- {
- self.b1 = String::from("Foo");
- }
- }
- fn main()
- {
- let mut a = A::new();
- a.foo();
- println!("{:?}", &a);
- }
Add Comment
Please, Sign In to add comment