Skip to content

Commit

Permalink
Merge pull request #462 from mgeisler/clippy
Browse files Browse the repository at this point in the history
Implement small recommendations from Clippy
  • Loading branch information
mgeisler committed Jul 9, 2022
2 parents 79bf25b + 56d663b commit 9c648da
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/line_ending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt::Debug;

/// Supported line endings. Like in the Rust standard library, two line
/// endings are supported: `\r\n` and `\n`
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LineEnding {
/// _Carriage return and line feed_ – a line ending sequence
/// historically used in Windows. Corresponds to the sequence
Expand Down Expand Up @@ -50,12 +50,11 @@ impl<'a> Iterator for NonEmptyLines<'a> {
self.0 = &self.0[(lf + 1)..];
return Some(trimmed);
}
if self.0.len() > 0 {
let result = Some((self.0, None));
self.0 = "";
return result;
if self.0.is_empty() {
None
} else {
return None;
let line = std::mem::take(&mut self.0);
Some((line, None))
}
}
}
Expand Down

0 comments on commit 9c648da

Please sign in to comment.