commented better
This commit is contained in:
parent
1736280dcd
commit
c3c2f41509
1 changed files with 2 additions and 2 deletions
|
@ -4,7 +4,7 @@ fn main()
|
||||||
|
|
||||||
let n = 5;
|
let n = 5;
|
||||||
let s = String::from("Learning Ownership");
|
let s = String::from("Learning Ownership");
|
||||||
take_ownership(s, n);
|
take_ownership(s, n);//s is moved n is copied
|
||||||
//println!("{}", s); It's gone
|
//println!("{}", s); It's gone
|
||||||
println!("Not Transferred, Just Copied = {}", n);
|
println!("Not Transferred, Just Copied = {}", n);
|
||||||
|
|
||||||
|
@ -15,4 +15,4 @@ fn take_ownership(our_string:String, our_number:i32)
|
||||||
//ownership is transferred for string
|
//ownership is transferred for string
|
||||||
println!("I got your String = {}", our_string);
|
println!("I got your String = {}", our_string);
|
||||||
println!("I got your Number = {}", our_number);
|
println!("I got your Number = {}", our_number);
|
||||||
} //calls drop for string, so our_string is gone now
|
} //calls "drop" for string, so our_string is gone now
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue