Last active
December 8, 2022 09:37
-
-
Save fatihgokce/78f38b8f4abd47d3ba64ba76c8075cf6 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
fn change(mut arr:[i32;6]){ | |
arr[0]=234; | |
let p=&arr; | |
//println!("into change address {:p}",p); | |
//println!("into cahange is {:?}", arr); | |
} | |
struct Point{ | |
x:i32, | |
y:i32, | |
} | |
fn main() { | |
let mut arr2: [i32;6] = [1, 2, 3, 4,5,6]; | |
let p=&arr2; | |
println!("main address {:p}",p); | |
change(arr2); | |
println!("after cahange is {:?}", arr2); | |
let s1=String::from("aa");//Point{x:1,y:2}; | |
let p2=&s1; | |
println!("p2:{:p} {:p} {:p} {:p}",p2,&s1,&p2,&s1[0..1]); | |
let s2=s1; | |
let p3=&s2; | |
println!("p3:{:p} {:p} {:p} {:p}",p3,&s2,&p3,&s2[0..1]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment