- for l in lines {
- if let Ok(l) = l {
- let l = l.as_ref().trim();
- // Allow (ignore) blank lines
- if l.is_empty() {
- continue;
- }
- // Expected format
- // <valid-hash><space><space-or-*><filename>
- let (line_alg, bytes, filename) = match l
- .find(' ')
- .and_then(|space_pos| {
- // Char before filename should be space for text or * for binary
- match l.chars().nth(space_pos + 1) {
- Some(' ') | Some('*') => (l.get(..space_pos)).zip(l.get(space_pos + 2..)),
- _ => None,
- }
- })
- .and_then(|(maybe_hash, filename)| {
- // Filename should be in this position without extra whitespace
- if filename.trim() == filename {
- try_parse_hash(maybe_hash).map(|(alg, bytes)| (alg, bytes, filename))
- } else {
- None
- }
- }) {
- Some(t) => t,
- None => {
- // if we have a line with content we cannot parse, this is an error
- return None;
+ for l in lines.flatten() {
+ let l = l.as_ref().trim();
+ // Allow (ignore) blank lines
+ if l.is_empty() {
+ continue;
+ }
+ // Expected format
+ // <valid-hash><space><space-or-*><filename>
+ let (line_alg, bytes, filename) = match l
+ .find(' ')
+ .and_then(|space_pos| {
+ // Char before filename should be space for text or * for binary
+ match l.chars().nth(space_pos + 1) {
+ Some(' ') | Some('*') => (l.get(..space_pos)).zip(l.get(space_pos + 2..)),
+ _ => None,