-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move word selector into a dedicated module
Also renamed RawWordSelector -> AsciiSortedWordSelector to better reflect what it does
- Loading branch information
Showing
4 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub mod ascii_raw; | ||
|
||
use std::io; | ||
|
||
/// Describes a thing that provides new words. | ||
pub trait WordSelector { | ||
/// Returns a new word. | ||
fn new_word(&mut self) -> Result<String, io::Error>; | ||
|
||
/// Returns a [`Vec`] containing `num_words` words. | ||
fn new_words(&mut self, num_words: usize) -> Result<Vec<String>, io::Error> { | ||
(0..num_words).map(|_| self.new_word()).collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters