-mod word_utils {
- pub fn first_word(s: &str) -> &str {
- for (i, &item) in s.as_bytes().iter().enumerate() {
- if item == b' ' {
- return &s[..i];
- }
- }
-
- s
- }
-
- pub fn second_word(s: &str) -> Option<&str> {
- for (i, &item) in s.as_bytes().iter().enumerate() {
- if item == b' ' {
- return Some(first_word(&s[(i + 1)..]));
- }
- }
-
- return None;
- }
-}
+mod word_utils;
use word_utils::{first_word, second_word};
--- /dev/null
+pub fn first_word(s: &str) -> &str {
+ for (i, &item) in s.as_bytes().iter().enumerate() {
+ if item == b' ' {
+ return &s[..i];
+ }
+ }
+
+ s
+}
+
+pub fn second_word(s: &str) -> Option<&str> {
+ for (i, &item) in s.as_bytes().iter().enumerate() {
+ if item == b' ' {
+ return Some(first_word(&s[(i + 1)..]));
+ }
+ }
+
+ return None;
+}