Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement small recommendations from Clippy #462

Merged
merged 1 commit into from
Jul 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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