Skip to content

Commit

Permalink
cleaner note_iter_into_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
khan5ula committed Oct 11, 2024
1 parent a4c71c8 commit 54f561b
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,12 @@ pub fn note_iter_into_vec<I>(iterator: I) -> Result<Vec<Note>, NoteError>
where
I: IntoIterator<Item = Result<Result<Note, String>, Error>>,
{
let mut result: Vec<Note> = vec![];

for iter_result in iterator {
match iter_result {
Ok(note_result) => match note_result {
Ok(note) => {
result.push(note);
}
Err(e) => {
return Err(NoteError::UnwrapNoteError(e));
}
},
Err(e) => {
return Err(NoteError::RustqliteError(e));
}
}
}

Ok(result)
iterator
.into_iter()
.map(|iter_result| {
iter_result
.map_err(NoteError::RustqliteError)?
.map_err(NoteError::UnwrapNoteError)
})
.collect()
}

0 comments on commit 54f561b

Please sign in to comment.