Use drop instead of the toilet closure |_| ()
This commit is contained in:
@@ -93,12 +93,12 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
|
||||
|
||||
unsafe {
|
||||
match ftruncate64.get() {
|
||||
Some(f) => cvt_r(|| f(fd, size as i64)).map(|_| ()),
|
||||
Some(f) => cvt_r(|| f(fd, size as i64)).map(drop),
|
||||
None => {
|
||||
if size > i32::max_value() as u64 {
|
||||
Err(io::Error::new(io::ErrorKind::InvalidInput, "cannot truncate >2GB"))
|
||||
} else {
|
||||
cvt_r(|| ftruncate(fd, size as i32)).map(|_| ())
|
||||
cvt_r(|| ftruncate(fd, size as i32)).map(drop)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
|
||||
unsafe { cvt_r(|| ftruncate(fd, size as i64)).map(|_| ()) }
|
||||
unsafe { cvt_r(|| ftruncate(fd, size as i64)).map(drop) }
|
||||
}
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
|
||||
@@ -814,7 +814,7 @@ impl File {
|
||||
use crate::convert::TryInto;
|
||||
let size: off64_t =
|
||||
size.try_into().map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
|
||||
cvt_r(|| unsafe { ftruncate64(self.0.raw(), size) }).map(|_| ())
|
||||
cvt_r(|| unsafe { ftruncate64(self.0.raw(), size) }).map(drop)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ impl Socket {
|
||||
|
||||
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
|
||||
let mut nonblocking = nonblocking as libc::c_int;
|
||||
cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(|_| ())
|
||||
cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(drop)
|
||||
}
|
||||
|
||||
pub fn take_error(&self) -> io::Result<Option<io::Error>> {
|
||||
|
||||
@@ -529,7 +529,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
|
||||
|
||||
unsafe {
|
||||
let _guard = env_lock();
|
||||
cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(|_| ())
|
||||
cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(drop)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ pub fn unsetenv(n: &OsStr) -> io::Result<()> {
|
||||
|
||||
unsafe {
|
||||
let _guard = env_lock();
|
||||
cvt(libc::unsetenv(nbuf.as_ptr())).map(|_| ())
|
||||
cvt(libc::unsetenv(nbuf.as_ptr())).map(drop)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,11 +99,11 @@ pub fn read2(p1: AnonPipe, v1: &mut Vec<u8>, p2: AnonPipe, v2: &mut Vec<u8>) ->
|
||||
|
||||
if fds[0].revents != 0 && read(&p1, v1)? {
|
||||
p2.set_nonblocking(false)?;
|
||||
return p2.read_to_end(v2).map(|_| ());
|
||||
return p2.read_to_end(v2).map(drop);
|
||||
}
|
||||
if fds[1].revents != 0 && read(&p2, v2)? {
|
||||
p1.set_nonblocking(false)?;
|
||||
return p1.read_to_end(v1).map(|_| ());
|
||||
return p1.read_to_end(v1).map(drop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +425,7 @@ impl Process {
|
||||
"invalid argument: can't kill an exited process",
|
||||
))
|
||||
} else {
|
||||
cvt(unsafe { libc::kill(self.pid, libc::SIGKILL) }).map(|_| ())
|
||||
cvt(unsafe { libc::kill(self.pid, libc::SIGKILL) }).map(drop)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user