Владение и звимствование #2

Open
CREATIVE_tg1 wants to merge 1 commits from владение_и_заимстование into main
Showing only changes of commit 4313addfdf - Show all commits

View File

@@ -1,3 +1,23 @@
fn main() { fn main() {
println!("Hello, world!"); println!("Base use owership");
base_use_owership();
println!();
println!("Base use borrowing");
base_use_borrowing();
println!();
}
fn base_use_owership() {
let city = String::from("Moscow");
let city_ref = &city;
println!("City: {}", city);
println!("City ref: {}", city_ref);
}
fn base_use_borrowing() {
let mut s1 = "hello".to_string();
let s2 = &mut s1;
s2.push('!');
println!("{}", s1);
} }