Mercurial > hg > Members > kono > rust-tutorial
changeset 2:d2f0d33c1586
add sub package
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 11 Jan 2021 16:27:48 +0900 |
parents | eb36163ce10b |
children | 9bb0201e638b |
files | Cargo.toml guessing/Cargo.toml guessing/src/main.rs src/main.rs src/t01guessing/src/main.rs |
diffstat | 5 files changed, 33 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Cargo.toml Mon Jan 11 15:08:31 2021 +0900 +++ b/Cargo.toml Mon Jan 11 16:27:48 2021 +0900 @@ -7,3 +7,10 @@ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] + +[workspace] + +members = [ + "guessing", + "src/t01guessing", +]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guessing/Cargo.toml Mon Jan 11 16:27:48 2021 +0900 @@ -0,0 +1,9 @@ +[package] +name = "guessing" +version = "0.1.0" +authors = ["Shinji KONO <kono@ie.u-ryukyu.ac.jp>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guessing/src/main.rs Mon Jan 11 16:27:48 2021 +0900 @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, guessing!"); +}
--- a/src/main.rs Mon Jan 11 15:08:31 2021 +0900 +++ b/src/main.rs Mon Jan 11 16:27:48 2021 +0900 @@ -1,3 +1,3 @@ fn main() { - println!("Hello, world!"); + println!("Hello, main!"); }
--- a/src/t01guessing/src/main.rs Mon Jan 11 15:08:31 2021 +0900 +++ b/src/t01guessing/src/main.rs Mon Jan 11 16:27:48 2021 +0900 @@ -1,3 +1,15 @@ +use std::io; + fn main() { - println!("Hello, world!"); + println!("Guess the number!"); + + println!("Please input your guess."); + + let mut guess = String::new(); + + io::stdin() + .read_line(&mut guess) + .expect("Failed to read line"); + + println!("You guessed: {}", guess); }