]> piware.de Git - learn-rust.git/blob - src/main.rs
Move word_utils to separate file
[learn-rust.git] / src / main.rs
1 mod word_utils;
2
3 use word_utils::{first_word, second_word};
4
5 fn main() {
6     let s = String::from("Hello world");
7     println!("first word: '{}'", first_word(&s));
8     println!("second word: '{}'", second_word(&s).unwrap());
9
10     let s2 = "hello dude blah";
11     println!("second word of single: '{}'", second_word(s2).unwrap_or("(none)"));
12
13     match second_word(s2) {
14         Some(w) => println!("match: second word of '{}' exists: {}", s2, w),
15         None => println!("match: second word of '{}' does not exist", s2),
16     }
17 }