Skip to content

Instantly share code, notes, and snippets.

@fatihgokce
Last active December 8, 2022 23:17
Show Gist options
  • Save fatihgokce/446518315dccbc83d34f6302ec1b04d7 to your computer and use it in GitHub Desktop.
Save fatihgokce/446518315dccbc83d34f6302ec1b04d7 to your computer and use it in GitHub Desktop.
#[derive(Debug)]
struct Point<'a>{
x:&'a str,
y:i32
}
fn main() {
let s1 = Point{x:"aa",y:3};//String::from("aa");
println!("p2:{:p} {:p} {:p}", s1.x,&s1.y,&s1);
let s2 = s1;
println!("p2:{:p} {:p} {:p}", s2.x,&s2.y,&s2);
let n=Point{x:"bb",y:12};//=String::from("aa");
println!("{:p}",&n.y);
let b1=Box::new(n);
println!("{:p} {:p}",&b1.y,b1);
let b2=b1;
println!("{:p} {:p}",&b2.y,b2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment