Some code.
Change-Id: Ia9b004074f83775dcb0310fc8104a63d1c17b51f
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..d95b684
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,47 @@
+#![allow(dead_code)]
+
+struct Person {
+ age: i32,
+ name: String,
+}
+
+impl ToString for Person {
+ fn to_string(&self) -> String {
+ format!("{} ({})", self.name, self.age)
+ }
+}
+
+fn greet_person_1(p: Person) {
+ println!("Hello {} ({})!", p.name, p.age);
+}
+
+fn greet_person_2(p: &Person) {
+ println!("Hello {} ({})!", p.name, p.age);
+}
+
+fn birthday(p: &mut Person) {
+ p.age += 1;
+}
+
+fn main() {
+ // -- Struct instantiation --
+ let mut p = Person { age: 30, name: "Mary".to_string() };
+
+ // -- Borrowing --
+ //greet_person_1(p);
+ //greet_person_1(p);
+
+ greet_person_2(&p);
+ greet_person_2(&p);
+
+ birthday(&mut p);
+
+ greet_person_2(&p);
+
+ // -- Traits --
+ println!("p = {}", p.to_string());
+
+ // -- Debugging --
+ let x = dbg!(100 + 2) + 3;
+ println!("Hello, world! 100 + 2 + 3 = {}", x);
+}