Created
December 15, 2020 14:05
-
-
Save BruJu/b66a1e8b24fd5ac0c678a672db96abe4 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
// https://play.rust-lang.org/ | |
#[derive(Debug)] | |
struct A { | |
x: u32 | |
} | |
fn main() { | |
let x = A { x: 7 }; | |
let option_x = Option::Some(&x); | |
let option_y = option_x; | |
print!("{:?}", option_x); // ok : option_x est copié car Option<référence vers A> | |
} |
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
#[derive(Debug)] | |
struct A { | |
x: u32 | |
} | |
fn main() { | |
let x = A { x: 7 }; | |
let option_x = Option::Some(x); | |
let option_y = option_x; // option_x n'existe plus (déplacement de option_x vers option_y | |
print!("{:?}", option_x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment