summaryrefslogtreecommitdiff
path: root/rust/chap4/simple_ref.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/chap4/simple_ref.rs')
-rw-r--r--rust/chap4/simple_ref.rs16
1 files changed, 16 insertions, 0 deletions
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");
+}