Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- // Fall For type 'String'
- let s1 = String::from("hello");
- let s2 = s1.clone();
- //let s2 = &s1; // OK
- //let s2 = s1; // ERROR
- // Fall For type 'str'
- //let s1 = "hello";
- //let s2 = s1;
- // let s2 = &s1; // OK
- //let s2 = s1.clone(); // OK
- println!("s1: the value of variable s1 is {}", s1);
- println!("s1: the stack address of variable s1 is {:p}", &s1);
- println!("s2: the value of variable s2 is {}", s2);
- println!("s2: the stack address of variable s2 is {:p}", &s2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement