Skip to content

Commit e862818

Browse files
committed
Fix Clippy warnings
1 parent 9100b09 commit e862818

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ macro_rules! impl_debug {
8989
$(#[$target])*
9090
$libc :: $flag => stringify!($flag),
9191
)+
92-
n => return write!(f, "{}", n),
92+
n => return write!(f, "{n}"),
9393
};
9494
f.write_str(string)
9595
}

tests/socket.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn domain_fmt_debug() {
7272
let mut buf = Vec::new();
7373
for (input, want) in tests {
7474
buf.clear();
75-
write!(buf, "{:?}", input).unwrap();
75+
write!(buf, "{input:?}").unwrap();
7676
let got = str::from_utf8(&buf).unwrap();
7777
assert_eq!(got, *want);
7878
}
@@ -93,7 +93,7 @@ fn type_fmt_debug() {
9393
let mut buf = Vec::new();
9494
for (input, want) in tests {
9595
buf.clear();
96-
write!(buf, "{:?}", input).unwrap();
96+
write!(buf, "{input:?}").unwrap();
9797
let got = str::from_utf8(&buf).unwrap();
9898
assert_eq!(got, *want);
9999
}
@@ -118,7 +118,7 @@ fn protocol_fmt_debug() {
118118
let mut buf = Vec::new();
119119
for (input, want) in tests {
120120
buf.clear();
121-
write!(buf, "{:?}", input).unwrap();
121+
write!(buf, "{input:?}").unwrap();
122122
let got = str::from_utf8(&buf).unwrap();
123123
assert_eq!(got, *want);
124124
}
@@ -323,7 +323,7 @@ where
323323
let mut flags = 0;
324324
if unsafe { GetHandleInformation(socket.as_raw_socket() as _, &mut flags) } == 0 {
325325
let err = io::Error::last_os_error();
326-
panic!("unexpected error: {}", err);
326+
panic!("unexpected error: {err}");
327327
}
328328
assert_eq!(
329329
flags & HANDLE_FLAG_INHERIT != 0,
@@ -365,8 +365,7 @@ where
365365
)
366366
};
367367
if res != 0 {
368-
let err = io::Error::last_os_error();
369-
panic!("unexpected error: {}", err);
368+
panic!("unexpected error: {}", io::Error::last_os_error());
370369
}
371370
assert_eq!(length as usize, size_of::<libc::c_int>());
372371
assert_eq!(flags, want as _, "non-blocking option");
@@ -382,8 +381,8 @@ fn connect_timeout_unrouteable() {
382381
let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap();
383382
match socket.connect_timeout(&addr, Duration::from_millis(250)) {
384383
Ok(_) => panic!("unexpected success"),
385-
Err(ref e) if e.kind() == io::ErrorKind::TimedOut => {}
386-
Err(e) => panic!("unexpected error {}", e),
384+
Err(ref err) if err.kind() == io::ErrorKind::TimedOut => {}
385+
Err(err) => panic!("unexpected error {}", err),
387386
}
388387
}
389388

@@ -399,10 +398,10 @@ fn connect_timeout_unbound() {
399398
let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap();
400399
match socket.connect_timeout(&addr, Duration::from_millis(250)) {
401400
Ok(_) => panic!("unexpected success"),
402-
Err(ref e)
403-
if e.kind() == io::ErrorKind::ConnectionRefused
404-
|| e.kind() == io::ErrorKind::TimedOut => {}
405-
Err(e) => panic!("unexpected error {}", e),
401+
Err(ref err)
402+
if err.kind() == io::ErrorKind::ConnectionRefused
403+
|| err.kind() == io::ErrorKind::TimedOut => {}
404+
Err(err) => panic!("unexpected error {}", err),
406405
}
407406
}
408407

@@ -445,7 +444,7 @@ fn unix_sockets_supported() -> bool {
445444
{
446445
return false;
447446
}
448-
Err(err) => panic!("socket error: {}", err),
447+
Err(err) => panic!("socket error: {err}"),
449448
}
450449
}
451450
true
@@ -804,7 +803,7 @@ fn device() {
804803
if let Err(err) = socket.bind_device(Some(interface.as_bytes())) {
805804
// Network interface is not available try another.
806805
if matches!(err.raw_os_error(), Some(libc::ENODEV)) {
807-
eprintln!("error binding to device (`{}`): {}", interface, err);
806+
eprintln!("error binding to device (`{interface}`): {err}");
808807
continue;
809808
} else {
810809
panic!("unexpected error binding device: {}", err);
@@ -844,7 +843,7 @@ fn device() {
844843
if let Err(err) = socket.bind_device_by_index(iface_index) {
845844
// Network interface is not available try another.
846845
if matches!(err.raw_os_error(), Some(libc::ENODEV)) {
847-
eprintln!("error binding to device (`{}`): {}", interface, err);
846+
eprintln!("error binding to device (`{interface}`): {err}");
848847
continue;
849848
} else {
850849
panic!("unexpected error binding device: {}", err);

0 commit comments

Comments
 (0)