Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created December 15, 2020 14:05
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 BruJu/b66a1e8b24fd5ac0c678a672db96abe4 to your computer and use it in GitHub Desktop.
Save BruJu/b66a1e8b24fd5ac0c678a672db96abe4 to your computer and use it in GitHub Desktop.
// 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>
}
#[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