From 93b1c04a218858ecc59b6b8929103695b7b8c2a0 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sat, 6 Sep 2025 09:30:14 +0200 Subject: Move rust playground here Signed-off-by: Carlos Maiolino --- rust/chap4/simple_ref.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 rust/chap4/simple_ref.rs (limited to 'rust/chap4/simple_ref.rs') diff --git a/rust/chap4/simple_ref.rs b/rust/chap4/simple_ref.rs new file mode 100644 index 0000000..968c025 --- /dev/null +++ b/rust/chap4/simple_ref.rs @@ -0,0 +1,16 @@ +fn main() { + let mut s = String::from("howdy"); + + change_me(&mut s); + + let size = get_str_size(&s); + println!("Size of s is {size}"); +} + +fn get_str_size(s: &String) -> usize { + return s.len(); +} + +fn change_me(s: &mut String) { + s.push_str(", brilha no curintia"); +} -- cgit v1.2.3