Permalink
Browse files

_

  • Loading branch information...
stnbu committed Nov 13, 2018
1 parent af75f10 commit 498cccb895cb8a9123874eb821d0bd2871c16586
Showing with 32 additions and 2 deletions.
  1. +29 −0 src/interactive.rs
  2. +3 −2 src/main.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();
}
@@ -66,12 +66,12 @@ fn hmap() {
fn wat() {
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 {
n: _Dingus,
}
let _z = Zoo { n: "foo" };
// In what other context can I use _dingus?
// ...In what other context can I use _Dingus?
}
fn main() {
@@ -81,4 +81,5 @@ fn main() {
hmap();
s_truct();
e_num();
o_ption();
}

0 comments on commit 498cccb

Please sign in to comment.