Created
January 10, 2022 16:51
-
-
Save dns2utf8/82641ac26448a722f3022280c0ca455e 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
// 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run on play.rust-lang.org