diff options
author | Alex Saveau <saveau.alexandre@gmail.com> | 2022-12-03 13:40:32 -0800 |
---|---|---|
committer | Alex Saveau <saveau.alexandre@gmail.com> | 2022-12-04 13:44:50 -0800 |
commit | fb802462a6c5c254f544dc2601ebe5ef8ab110bc (patch) | |
tree | b79fe64a43077760ec7ec73cce54d0a93fa52d61 /src/sys | |
parent | e2ff9d53b66b719f3d356604497747d87a7474a5 (diff) | |
download | nix-fb802462a6c5c254f544dc2601ebe5ef8ab110bc.zip |
Fix clippy lints
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/aio.rs | 2 | ||||
-rw-r--r-- | src/sys/socket/addr.rs | 6 | ||||
-rw-r--r-- | src/sys/socket/mod.rs | 1 | ||||
-rw-r--r-- | src/sys/socket/sockopt.rs | 5 | ||||
-rw-r--r-- | src/sys/time.rs | 32 |
5 files changed, 20 insertions, 26 deletions
diff --git a/src/sys/aio.rs b/src/sys/aio.rs index e2ce19b7..ee78d9c2 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -163,7 +163,7 @@ impl AioCb { 0 => Ok(()), num if num > 0 => Err(Errno::from_i32(num)), -1 => Err(Errno::last()), - num => panic!("unknown aio_error return value {:?}", num), + num => panic!("unknown aio_error return value {num:?}"), } } diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index d83adcfe..4e36ca47 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -2373,7 +2373,7 @@ mod tests { sdl_slen: 0, ..unsafe { mem::zeroed() } }); - format!("{}", la); + format!("{la}"); } #[cfg(all( @@ -2495,7 +2495,7 @@ mod tests { fn display() { let s = "127.0.0.1:8080"; let addr = SockaddrIn::from_str(s).unwrap(); - assert_eq!(s, format!("{}", addr)); + assert_eq!(s, format!("{addr}")); } #[test] @@ -2515,7 +2515,7 @@ mod tests { fn display() { let s = "[1234:5678:90ab:cdef::1111:2222]:8080"; let addr = SockaddrIn6::from_str(s).unwrap(); - assert_eq!(s, format!("{}", addr)); + assert_eq!(s, format!("{addr}")); } #[test] diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index eea74cf6..5dac8698 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -12,7 +12,6 @@ use libc::{ self, c_int, c_void, iovec, size_t, socklen_t, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR, }; -use std::convert::TryFrom; use std::io::{IoSlice, IoSliceMut}; #[cfg(feature = "net")] use std::net; diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 4e0abfbe..c2daeae7 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -6,13 +6,10 @@ use crate::Result; use cfg_if::cfg_if; use libc::{self, c_int, c_void, socklen_t}; use std::ffi::{OsStr, OsString}; +use std::mem::{self, MaybeUninit}; #[cfg(target_family = "unix")] use std::os::unix::ffi::OsStrExt; use std::os::unix::io::RawFd; -use std::{ - convert::TryFrom, - mem::{self, MaybeUninit}, -}; // Constants // TCP_CA_NAME_MAX isn't defined in user space include files diff --git a/src/sys/time.rs b/src/sys/time.rs index 0042c450..a1894e4d 100644 --- a/src/sys/time.rs +++ b/src/sys/time.rs @@ -261,8 +261,7 @@ impl TimeValLike for TimeSpec { fn seconds(seconds: i64) -> TimeSpec { assert!( (TS_MIN_SECONDS..=TS_MAX_SECONDS).contains(&seconds), - "TimeSpec out of bounds; seconds={}", - seconds + "TimeSpec out of bounds; seconds={seconds}", ); let mut ts = zero_init_timespec(); ts.tv_sec = seconds as time_t; @@ -428,20 +427,20 @@ impl fmt::Display for TimeSpec { let sec = abs.tv_sec(); - write!(f, "{}", sign)?; + write!(f, "{sign}")?; if abs.tv_nsec() == 0 { - if abs.tv_sec() == 1 { - write!(f, "{} second", sec)?; + if sec == 1 { + write!(f, "1 second")?; } else { - write!(f, "{} seconds", sec)?; + write!(f, "{sec} seconds")?; } } else if abs.tv_nsec() % 1_000_000 == 0 { - write!(f, "{}.{:03} seconds", sec, abs.tv_nsec() / 1_000_000)?; + write!(f, "{sec}.{:03} seconds", abs.tv_nsec() / 1_000_000)?; } else if abs.tv_nsec() % 1_000 == 0 { - write!(f, "{}.{:06} seconds", sec, abs.tv_nsec() / 1_000)?; + write!(f, "{sec}.{:06} seconds", abs.tv_nsec() / 1_000)?; } else { - write!(f, "{}.{:09} seconds", sec, abs.tv_nsec())?; + write!(f, "{sec}.{:09} seconds", abs.tv_nsec())?; } Ok(()) @@ -497,8 +496,7 @@ impl TimeValLike for TimeVal { fn seconds(seconds: i64) -> TimeVal { assert!( (TV_MIN_SECONDS..=TV_MAX_SECONDS).contains(&seconds), - "TimeVal out of bounds; seconds={}", - seconds + "TimeVal out of bounds; seconds={seconds}" ); #[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848 @@ -662,18 +660,18 @@ impl fmt::Display for TimeVal { let sec = abs.tv_sec(); - write!(f, "{}", sign)?; + write!(f, "{sign}")?; if abs.tv_usec() == 0 { - if abs.tv_sec() == 1 { - write!(f, "{} second", sec)?; + if sec == 1 { + write!(f, "1 second")?; } else { - write!(f, "{} seconds", sec)?; + write!(f, "{sec} seconds")?; } } else if abs.tv_usec() % 1000 == 0 { - write!(f, "{}.{:03} seconds", sec, abs.tv_usec() / 1000)?; + write!(f, "{sec}.{:03} seconds", abs.tv_usec() / 1000)?; } else { - write!(f, "{}.{:06} seconds", sec, abs.tv_usec())?; + write!(f, "{sec}.{:06} seconds", abs.tv_usec())?; } Ok(()) |