fix: ✏️ typos and compiler warnings

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-06-17 18:19:36 +03:00
parent 82c2fb8883
commit 528969944d
17 changed files with 578 additions and 632 deletions

View file

@ -1,29 +1,25 @@
fn main()
{
println!("Hello, world!");
let n = 5;
let s1 = String::from("Learning Ownership");
take_ownership(s1, n);//s1 is moved n is copied
//println!("{}", s1); It's gone
println!("Not Transferred, Just Copied = {}", n);
let s2 = String::from("Be Right Back");
let s3 = take_then_give_back_ownership(s2);
//println!("s2 = {}", s2); s2 is long gone
println!("s3 = {}", s3);
fn main() {
println!("Hello, world!");
}
let n = 5;
let s1 = String::from("Learning Ownership");
take_ownership(s1, n); //s1 is moved n is copied
//println!("{}", s1); 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
let s2 = String::from("Be Right Back");
let s3 = take_then_give_back_ownership(s2);
//println!("s2 = {}", s2); s2 is long gone
println!("s3 = {}", s3);
}
fn take_then_give_back_ownership(our_string:String) -> String
{
println!("Now String is Here = {}", our_string);
our_string
}
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
fn take_then_give_back_ownership(our_string: String) -> String {
println!("Now String is Here = {}", our_string);
our_string
}