From 4313addfdf7b36cc391e2e5fccf87b2acfd79cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=82=D0=BA=D0=B8=D0=BD=D0=90=D1=80=D1=82?= =?UTF-8?q?=D1=91=D0=BC?= Date: Thu, 6 Nov 2025 13:46:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B8=20=D0=B7=D0=B2=D0=B8=D0=BC=D1=81=D1=82=D0=B2?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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); }