Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. fn main() {
  2. // Fall For type 'String'
  3. let s1 = String::from("hello");
  4. let s2 = s1.clone();
  5. //let s2 = &s1; // OK
  6. //let s2 = s1; // ERROR
  7.  
  8. // Fall For type 'str'
  9. //let s1 = "hello";
  10. //let s2 = s1;
  11. // let s2 = &s1; // OK
  12. //let s2 = s1.clone(); // OK
  13.  
  14. println!("s1: the value of variable s1 is {}", s1);
  15. println!("s1: the stack address of variable s1 is {:p}", &s1);
  16. println!("s2: the value of variable s2 is {}", s2);
  17. println!("s2: the stack address of variable s2 is {:p}", &s2);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement