Skip to content

Commit

Permalink
_
Browse files Browse the repository at this point in the history
  • Loading branch information
stnbu committed Nov 13, 2018
1 parent af75f10 commit 498cccb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/interactive.rs
@@ -0,0 +1,29 @@
fn o_ption() {
println!("what's your name, noble worrior?");
let mut buf = String::new();
use std::io;
io::stdin().read_line(&mut buf)
.ok()
.expect("Failed to read stdin");
let buf = buf.trim();
println!("{}, that's a mighty name indeeeeed.", buf);
}

fn p_arse() {
let mut buf = String::new();
println!("Enter a number: ");
use std::io;
io::stdin().read_line(&mut buf)
.ok()
.expect("Not a number!");
let input_num: Result<u32, _> = buf.trim().parse();
match input_num {
Ok(num) => println!("You entered the number {}", num),
Err(ex) => println!("Cannot be parsed as a number: {}", ex)
};
}

fn main() {
o_ption();
p_arse();
}
5 changes: 3 additions & 2 deletions src/main.rs
Expand Up @@ -66,12 +66,12 @@ fn hmap() {


fn wat() { fn wat() {
type _Dingus = &'static str; type _Dingus = &'static str;
// what the heck is going on here? I the book says // what the heck is going on here? I the book says...
struct Zoo { struct Zoo {
n: _Dingus, n: _Dingus,
} }
let _z = Zoo { n: "foo" }; let _z = Zoo { n: "foo" };
// In what other context can I use _dingus? // ...In what other context can I use _Dingus?
} }


fn main() { fn main() {
Expand All @@ -81,4 +81,5 @@ fn main() {
hmap(); hmap();
s_truct(); s_truct();
e_num(); e_num();
o_ption();
} }

0 comments on commit 498cccb

Please sign in to comment.