Created
August 11, 2022 22:28
-
-
Save computermouth/1a7b46a7a2156d13c747de46359352fc 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
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