diff --git a/src/main.rs b/src/main.rs index e7a11a9..b6211a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,23 @@ 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); }