From 64e231a8c60478b04bffa66eae1fe513cf4b5f73 Mon Sep 17 00:00:00 2001 From: Alexander Launi Date: Sat, 21 Mar 2020 16:16:22 -0400 Subject: [PATCH] Add greet example in Rust --- 03_recursion/rust/02_greet/.gitignore | 10 ++++++++++ 03_recursion/rust/02_greet/Cargo.toml | 9 +++++++++ 03_recursion/rust/02_greet/src/main.rs | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 03_recursion/rust/02_greet/.gitignore create mode 100644 03_recursion/rust/02_greet/Cargo.toml create mode 100644 03_recursion/rust/02_greet/src/main.rs diff --git a/03_recursion/rust/02_greet/.gitignore b/03_recursion/rust/02_greet/.gitignore new file mode 100644 index 0000000..088ba6b --- /dev/null +++ b/03_recursion/rust/02_greet/.gitignore @@ -0,0 +1,10 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk diff --git a/03_recursion/rust/02_greet/Cargo.toml b/03_recursion/rust/02_greet/Cargo.toml new file mode 100644 index 0000000..98268b0 --- /dev/null +++ b/03_recursion/rust/02_greet/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "greet" +version = "0.1.0" +authors = ["Alexander Launi "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/03_recursion/rust/02_greet/src/main.rs b/03_recursion/rust/02_greet/src/main.rs new file mode 100644 index 0000000..8f90eb0 --- /dev/null +++ b/03_recursion/rust/02_greet/src/main.rs @@ -0,0 +1,18 @@ +fn greet2(name: &str) { + println!("how are you {}?", name); +} + +fn bye() { + println!("ok bye!"); +} + +fn greet(name: &str) { + println!("hello {}!", name); + greet2(name); + println!("getting ready to say bye..."); + bye(); +} + +fn main() { + greet("adit"); +}