Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created Dec 15, 2020
Embed
What would you like to do?
// 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