Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
daschr committed Sep 16, 2023
1 parent ed64d17 commit cd8342a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ impl Hosts {
while reader.read_line(&mut line)? != 0 {
let tr_line = line.trim();

if tr_line.starts_with("#")
if tr_line.starts_with('#')
&& tr_line
.trim_start_matches(&['#', ' '])
.trim_start_matches(['#', ' '])
.starts_with("SECTION")
{
let new_section_name = match tr_line.split(' ').last() {
Some(name) if name != "SECTION" => name,
_ => continue,
};

if entries.len() > 0 {
if !entries.is_empty() {
sections.insert(current_section, entries.clone());
entries.clear();
}
Expand All @@ -51,7 +51,7 @@ impl Hosts {
line.clear();
}

if entries.len() > 0 {
if !entries.is_empty() {
sections.insert(current_section, entries);
}

Expand All @@ -77,7 +77,7 @@ impl Hosts {
if let Some(entries) = self.sections.remove(&None) {
for e in entries.iter() {
writer.write_all(e.as_bytes())?;
writer.write_all(&['\n' as u8])?;
writer.write_all(&[b'\n'])?;
}
}

Expand All @@ -87,7 +87,7 @@ impl Hosts {

for e in entries.iter() {
writer.write_all(e.as_bytes())?;
writer.write_all(&['\n' as u8])?;
writer.write_all(&[b'\n'])?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() -> Result<(), IoError> {
}
};

if container_entries.len() == 0 {
if container_entries.is_empty() {
exit(0);
}

Expand Down

0 comments on commit cd8342a

Please sign in to comment.