Add greet example in Rust

This commit is contained in:
Alexander Launi
2020-03-21 16:16:22 -04:00
parent 858e1e71e7
commit 64e231a8c6
3 changed files with 37 additions and 0 deletions

10
03_recursion/rust/02_greet/.gitignore vendored Normal file
View File

@@ -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

View File

@@ -0,0 +1,9 @@
[package]
name = "greet"
version = "0.1.0"
authors = ["Alexander Launi <alex.launi@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -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");
}