Implement Dictionary::load_from_iterable

This commit is contained in:
Blallo 2020-05-18 16:44:29 +02:00
parent ded6795623
commit c9c21d7dfd
No known key found for this signature in database
GPG key ID: 0CBE577C9B72DC3F

View file

@ -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}