Skip to content

Instantly share code, notes, and snippets.

@JoJoDeveloping
Created October 5, 2026 12:03
Show Gist options
  • Select an option

  • Save JoJoDeveloping/1c62f119f98ab299f97490d7ac32452c to your computer and use it in GitHub Desktop.

Select an option

Save JoJoDeveloping/1c62f119f98ab299f97490d7ac32452c to your computer and use it in GitHub Desktop.
pub fn f(a: &mut i32, b: &mut i32, c: &mut i32, cond: bool) {
let y;
let z;
if cond {
y = &mut *a;
z = &mut *b;
} else {
y = &mut *b;
z = &mut *c;
}
*a += 1;
*z += 1;
}
fn main() {
let mut a = 3;
let mut b = 4;
let mut c = 5;
f(&mut a, &mut b, &mut c, true);
assert_eq!(a, 4);
assert_eq!(b, 5);
assert_eq!(c, 5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment