Skip to content

Instantly share code, notes, and snippets.

@steveklabnik
Forked from stat/mutable references
Created November 14, 2016 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveklabnik/0422faad24f1dbf4410be0279e5219ed to your computer and use it in GitHub Desktop.
Save steveklabnik/0422faad24f1dbf4410be0279e5219ed to your computer and use it in GitHub Desktop.
fn add_to_mutable_reference(x: &mut i32) {
*x +=1;
}
#[test]
fn mutable_reference_test() {
let mut x = 5;
let y = &mut x;
mutable_reference(y);
assert_eq!(6, x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment