Add phrases example
This commit is contained in:
parent
4b413c9e54
commit
b48021c07a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.DS_Store
|
||||
**/target
|
||||
**/node_modules
|
4
phrases/Cargo.lock
generated
Normal file
4
phrases/Cargo.lock
generated
Normal file
@ -0,0 +1,4 @@
|
||||
[root]
|
||||
name = "phrases"
|
||||
version = "0.1.0"
|
||||
|
4
phrases/Cargo.toml
Normal file
4
phrases/Cargo.toml
Normal file
@ -0,0 +1,4 @@
|
||||
[package]
|
||||
name = "phrases"
|
||||
version = "0.1.0"
|
||||
authors = ["Tim Warren <twarren@nexient.com>"]
|
3
phrases/src/english/farewells.rs
Normal file
3
phrases/src/english/farewells.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn goodbye() -> String {
|
||||
"Goodbye.".to_string()
|
||||
}
|
3
phrases/src/english/greetings.rs
Normal file
3
phrases/src/english/greetings.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn hello() -> String {
|
||||
"Hello!".to_string()
|
||||
}
|
2
phrases/src/english/mod.rs
Normal file
2
phrases/src/english/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod greetings;
|
||||
pub mod farewells;
|
3
phrases/src/japanese/farewells.rs
Normal file
3
phrases/src/japanese/farewells.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn goodbye() -> String {
|
||||
"さようなら".to_string()
|
||||
}
|
3
phrases/src/japanese/greetings.rs
Normal file
3
phrases/src/japanese/greetings.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn hello() -> String {
|
||||
"こんにちは".to_string()
|
||||
}
|
2
phrases/src/japanese/mod.rs
Normal file
2
phrases/src/japanese/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod greetings;
|
||||
pub mod farewells;
|
2
phrases/src/lib.rs
Normal file
2
phrases/src/lib.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod english;
|
||||
pub mod japanese;
|
14
phrases/src/main.rs
Normal file
14
phrases/src/main.rs
Normal file
@ -0,0 +1,14 @@
|
||||
extern crate phrases;
|
||||
|
||||
use phrases::english::greetings as en_greetings;
|
||||
use phrases::english::farewells as en_farewells;
|
||||
use phrases::japanese::greetings as ja_greetings;
|
||||
use phrases::japanese::farewells as ja_farewells;
|
||||
|
||||
|
||||
fn main() {
|
||||
println!("Hello in English; {}", en_greetings::hello());
|
||||
println!("And in Japanese: {}", ja_greetings::hello());
|
||||
println!("Goodbye in English: {}", en_farewells::goodbye());
|
||||
println!("And in Japanese: {}", ja_farewells::goodbye());
|
||||
}
|
Reference in New Issue
Block a user