Skip to content

Instantly share code, notes, and snippets.

@richo
Created December 27, 2020 01:01
Show Gist options
  • Save richo/ab3a38cbfc07c54aa0b290036ccaf7b8 to your computer and use it in GitHub Desktop.
Save richo/ab3a38cbfc07c54aa0b290036ccaf7b8 to your computer and use it in GitHub Desktop.
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