changed their order
This commit is contained in:
parent
11cf6d0135
commit
1736280dcd
4 changed files with 0 additions and 0 deletions
8
11-ownership/Cargo.toml
Normal file
8
11-ownership/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "ownership"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
18
11-ownership/src/main.rs
Normal file
18
11-ownership/src/main.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
fn main()
|
||||
{
|
||||
println!("Hello, world!");
|
||||
|
||||
let n = 5;
|
||||
let s = String::from("Learning Ownership");
|
||||
take_ownership(s, n);
|
||||
//println!("{}", s); It's gone
|
||||
println!("Not Transferred, Just Copied = {}", n);
|
||||
|
||||
}
|
||||
|
||||
fn take_ownership(our_string:String, our_number:i32)
|
||||
{
|
||||
//ownership is transferred for string
|
||||
println!("I got your String = {}", our_string);
|
||||
println!("I got your Number = {}", our_number);
|
||||
} //calls drop for string, so our_string is gone now
|
Loading…
Add table
Add a link
Reference in a new issue