Browse Source

Use newline variants of write macro

These were flagged by `cargo clippy`:

    warning: using `println!("")`
    warning: using `write!()` with a format string that ends in a single
             newline
Alex Crawford 4 years ago
parent
commit
113a6c16b8
3 changed files with 4 additions and 4 deletions
  1. 1 1
      src/socket/tcp.rs
  2. 2 2
      src/wire/igmp.rs
  3. 1 1
      src/wire/pretty_print.rs

+ 1 - 1
src/socket/tcp.rs

@@ -1891,7 +1891,7 @@ mod test {
         let _ = log::set_logger(&LOGGER);
         log::set_max_level(log::LevelFilter::Trace);
 
-        println!("");
+        println!();
     }
 
     fn socket() -> TcpSocket<'static> {

+ 2 - 2
src/wire/igmp.rs

@@ -363,8 +363,8 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
                     indent: &mut PrettyIndent)
                     -> fmt::Result {
         match Packet::new_checked(buffer) {
-            Err(err) => write!(f, "{}({})\n", indent, err),
-            Ok(packet) => write!(f, "{}{}\n", indent, packet),
+            Err(err) => writeln!(f, "{}({})", indent, err),
+            Ok(packet) => writeln!(f, "{}{}", indent, packet),
         }
     }
 }

+ 1 - 1
src/wire/pretty_print.rs

@@ -48,7 +48,7 @@ impl PrettyIndent {
 
     /// Increase indentation level.
     pub fn increase(&mut self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "\n")?;
+        writeln!(f)?;
         self.level += 1;
         Ok(())
     }