From b48021c07a244f38d34a0856326f67f7a3ab6f3d Mon Sep 17 00:00:00 2001 From: Tim Warren Date: Wed, 16 Dec 2015 09:08:59 -0500 Subject: [PATCH] Add phrases example --- .gitignore | 1 + phrases/Cargo.lock | 4 ++++ phrases/Cargo.toml | 4 ++++ phrases/src/english/farewells.rs | 3 +++ phrases/src/english/greetings.rs | 3 +++ phrases/src/english/mod.rs | 2 ++ phrases/src/japanese/farewells.rs | 3 +++ phrases/src/japanese/greetings.rs | 3 +++ phrases/src/japanese/mod.rs | 2 ++ phrases/src/lib.rs | 2 ++ phrases/src/main.rs | 14 ++++++++++++++ 11 files changed, 41 insertions(+) create mode 100644 phrases/Cargo.lock create mode 100644 phrases/Cargo.toml create mode 100644 phrases/src/english/farewells.rs create mode 100644 phrases/src/english/greetings.rs create mode 100644 phrases/src/english/mod.rs create mode 100644 phrases/src/japanese/farewells.rs create mode 100644 phrases/src/japanese/greetings.rs create mode 100644 phrases/src/japanese/mod.rs create mode 100644 phrases/src/lib.rs create mode 100644 phrases/src/main.rs diff --git a/.gitignore b/.gitignore index 7ae3820..1e70055 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.DS_Store **/target **/node_modules \ No newline at end of file diff --git a/phrases/Cargo.lock b/phrases/Cargo.lock new file mode 100644 index 0000000..4cd885b --- /dev/null +++ b/phrases/Cargo.lock @@ -0,0 +1,4 @@ +[root] +name = "phrases" +version = "0.1.0" + diff --git a/phrases/Cargo.toml b/phrases/Cargo.toml new file mode 100644 index 0000000..2bb0b2b --- /dev/null +++ b/phrases/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "phrases" +version = "0.1.0" +authors = ["Tim Warren "] diff --git a/phrases/src/english/farewells.rs b/phrases/src/english/farewells.rs new file mode 100644 index 0000000..de24c8c --- /dev/null +++ b/phrases/src/english/farewells.rs @@ -0,0 +1,3 @@ +pub fn goodbye() -> String { + "Goodbye.".to_string() +} \ No newline at end of file diff --git a/phrases/src/english/greetings.rs b/phrases/src/english/greetings.rs new file mode 100644 index 0000000..ec59ef4 --- /dev/null +++ b/phrases/src/english/greetings.rs @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello!".to_string() +} \ No newline at end of file diff --git a/phrases/src/english/mod.rs b/phrases/src/english/mod.rs new file mode 100644 index 0000000..5b564bd --- /dev/null +++ b/phrases/src/english/mod.rs @@ -0,0 +1,2 @@ +pub mod greetings; +pub mod farewells; \ No newline at end of file diff --git a/phrases/src/japanese/farewells.rs b/phrases/src/japanese/farewells.rs new file mode 100644 index 0000000..14ed4d2 --- /dev/null +++ b/phrases/src/japanese/farewells.rs @@ -0,0 +1,3 @@ +pub fn goodbye() -> String { + "さようなら".to_string() +} \ No newline at end of file diff --git a/phrases/src/japanese/greetings.rs b/phrases/src/japanese/greetings.rs new file mode 100644 index 0000000..038ba51 --- /dev/null +++ b/phrases/src/japanese/greetings.rs @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "こんにちは".to_string() +} \ No newline at end of file diff --git a/phrases/src/japanese/mod.rs b/phrases/src/japanese/mod.rs new file mode 100644 index 0000000..5b564bd --- /dev/null +++ b/phrases/src/japanese/mod.rs @@ -0,0 +1,2 @@ +pub mod greetings; +pub mod farewells; \ No newline at end of file diff --git a/phrases/src/lib.rs b/phrases/src/lib.rs new file mode 100644 index 0000000..bfabb38 --- /dev/null +++ b/phrases/src/lib.rs @@ -0,0 +1,2 @@ +pub mod english; +pub mod japanese; \ No newline at end of file diff --git a/phrases/src/main.rs b/phrases/src/main.rs new file mode 100644 index 0000000..6a09ff7 --- /dev/null +++ b/phrases/src/main.rs @@ -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()); +} \ No newline at end of file