Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug, Default)]
- struct Foo { a: String, b: String }
- impl Foo {
- fn get_mut_a_b(&mut self) -> (&mut String, &mut String) {
- (&mut self.a, &mut self.b)
- }
- }
- fn main() {
- let mut foo = Foo::default();
- {
- let (a, b) = foo.get_mut_a_b();
- a.push_str("Hello");
- b.insert_str(0, "World");
- }
- println!("{:#?}", foo);
- }
Add Comment
Please, Sign In to add comment