1 Commits

Author SHA1 Message Date
ВяткинАртём
4313addfdf Владение и звимствование 2025-11-06 13:46:38 +03:00

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);
} }