Created
December 27, 2020 01:01
-
-
Save richo/ab3a38cbfc07c54aa0b290036ccaf7b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Thing { | |
inner: Inner, | |
} | |
struct Inner { | |
name: Composite, | |
} | |
struct Composite { | |
t1: String, | |
t2: String, | |
} | |
pub fn boop() { | |
let mut thing = Thing{ | |
inner: Inner { | |
name: Composite { | |
t1: "t1".into(), | |
t2: "t2".into(), | |
} | |
} | |
}; | |
thing.rename("butts".into()); | |
} | |
impl Thing { | |
fn rename(&mut self, newname: String) { | |
let old = self.inner.name; | |
self.inner.name = Composite { | |
t1: old.t1, | |
t2: newname, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment