use word_utils::{first_word, second_word};
-fn main() {
- // strings and functions
+fn test_strings() {
let s = String::from("Hello world");
println!("first word: '{}'", first_word(&s));
println!("second word: '{}'", second_word(&s).unwrap());
Some(w) => println!("match: second word of '{}' exists: {}", s2, w),
None => println!("match: second word of '{}' does not exist", s2),
}
+}
- // vectors
+fn test_vectors() {
let v1 = vec![1, 2, 3];
println!("statically initialized vector: {:?}", v1);
for el in &v2 {
println!("{}", el);
}
+}
- // hash maps
+fn test_hashmaps() {
let mut scores = HashMap::new();
scores.insert("john", 10);
scores.insert("mary", 20);
.collect();
println!("collect_scores after rebuilding with doubling: {:?}", collect_scores);
}
+
+fn main() {
+ test_strings();
+ test_vectors();
+ test_hashmaps();
+}