pub fn ownership_fn(){
let x = 5;
let y = x;
println!("{}", y);
let s1 = String::from("hello world!");
let s2 = s1;
let s3 = s2.clone();
let s3 = give_ownership(s3);
let s4 = give_ownership(s3);
let s5 = take_ownership_ref(&s4);
let mut s6 = String::from("Hello World!");
let r1 = & s6;
let r3 = &mut s6;
}
fn change(str:&mut String){
print!("The value of the variable is changed from: {}", str);
str.push_str(" This is great!");
println!("\nto: {}", str);
}
fn take_ownership(str:String) -> String{
println!("This also moves the value of the variable to the function: {}", str);
str
}
fn take_ownership_ref(str: &String){
println!("The value of the variable is passed to the function as a reference: {}", str);
}
fn give_ownership(str:String) -> String{
println!("The ownership's value: {}", str);
str
}
fn take_and_give_ownership(str:String) -> String{
println!("This also moves the value of the variable to another variable: {}", str);
str
}