Implement Dictionary::load_from_iterable
This commit is contained in:
parent
ded6795623
commit
c9c21d7dfd
1 changed files with 11 additions and 0 deletions
11
src/main.rs
11
src/main.rs
|
@ -14,6 +14,17 @@ struct Dictionary {
|
|||
iter_position: usize,
|
||||
}
|
||||
|
||||
impl Dictionary {
|
||||
fn load_from_iterable(
|
||||
&mut self,
|
||||
lines: impl Iterator<Item = Result<String, Error>>,
|
||||
) -> Result<(), std::io::Error> {
|
||||
lines
|
||||
.map(|line| line.and_then(|line_str| Ok(self.words.push(line_str))))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
/*impl Dictionary {
|
||||
fn default() -> Dictionary {
|
||||
Dictionary{words: vec![], iter_position: 0}
|
||||
|
|
Reference in a new issue