Skip to content

Instantly share code, notes, and snippets.

@dns2utf8
Created January 10, 2022 16:51
Show Gist options
  • Save dns2utf8/82641ac26448a722f3022280c0ca455e to your computer and use it in GitHub Desktop.
Save dns2utf8/82641ac26448a722f3022280c0ca455e to your computer and use it in GitHub Desktop.
// Source: https://gist.github.com/dns2utf8/82641ac26448a722f3022280c0ca455e
#[derive(Debug)]
struct A { value: isize }
impl A {
fn borrow_value(&mut self) -> &mut isize {
&mut self.value
}
}
fn main() {
let mut a = A { value: 42 };
*a.borrow_value() = 23;
println!("{:?}", a);
}
@dns2utf8
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment