Skip to content

Instantly share code, notes, and snippets.

@computermouth
Created August 11, 2022 22:28
Show Gist options
  • Save computermouth/1a7b46a7a2156d13c747de46359352fc to your computer and use it in GitHub Desktop.
Save computermouth/1a7b46a7a2156d13c747de46359352fc to your computer and use it in GitHub Desktop.
struct Mytype {
a: isize,
}
fn inc_mytype(m: Mytype) -> isize {
m.a + 1
}
fn inc_isize(i: isize) -> isize {
i + 1
}
fn main() {
let mut a = 1;
println!("a: {}", inc_isize(a));
a = 2;
println!("a: {}", inc_isize(a));
let mut m = Mytype{ a: 1 };
println!("a: {}", inc_mytype(m));
m.a = 2;
println!("a: {}", inc_mytype(m));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment