Add phrases example

This commit is contained in:
Tim Warren 2015-12-16 09:08:59 -05:00
parent 4b413c9e54
commit b48021c07a
11 changed files with 41 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.DS_Store
**/target **/target
**/node_modules **/node_modules

4
phrases/Cargo.lock generated Normal file
View File

@ -0,0 +1,4 @@
[root]
name = "phrases"
version = "0.1.0"

4
phrases/Cargo.toml Normal file
View File

@ -0,0 +1,4 @@
[package]
name = "phrases"
version = "0.1.0"
authors = ["Tim Warren <twarren@nexient.com>"]

View File

@ -0,0 +1,3 @@
pub fn goodbye() -> String {
"Goodbye.".to_string()
}

View File

@ -0,0 +1,3 @@
pub fn hello() -> String {
"Hello!".to_string()
}

View File

@ -0,0 +1,2 @@
pub mod greetings;
pub mod farewells;

View File

@ -0,0 +1,3 @@
pub fn goodbye() -> String {
"さようなら".to_string()
}

View File

@ -0,0 +1,3 @@
pub fn hello() -> String {
"こんにちは".to_string()
}

View File

@ -0,0 +1,2 @@
pub mod greetings;
pub mod farewells;

2
phrases/src/lib.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod english;
pub mod japanese;

14
phrases/src/main.rs Normal file
View 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());
}