From e26ab7b58b9e752b17f50774ead518831179b1f9 Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Thu, 25 Jan 2018 20:39:56 -0800 Subject: Don't use map(drop) as it's hard to understand .map(drop) makes it seem like there is a need to drop the type at that point when really all you're doing is trying to erase the type information and return an empty tuple. So do that explicitly instead of throwing drop in there. --- src/sys/termios.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/sys') diff --git a/src/sys/termios.rs b/src/sys/termios.rs index 352dcb79..4bed6665 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -928,7 +928,7 @@ cfg_if!{ let inner_termios = unsafe { termios.get_libc_termios_mut() }; let res = unsafe { libc::cfsetispeed(inner_termios, baud.into() as libc::speed_t) }; termios.update_wrapper(); - Errno::result(res).map(drop) + Errno::result(res).map(|_| ()) } /// Set output baud rate (see @@ -939,7 +939,7 @@ cfg_if!{ let inner_termios = unsafe { termios.get_libc_termios_mut() }; let res = unsafe { libc::cfsetospeed(inner_termios, baud.into() as libc::speed_t) }; termios.update_wrapper(); - Errno::result(res).map(drop) + Errno::result(res).map(|_| ()) } /// Set both the input and output baud rates (see @@ -951,7 +951,7 @@ cfg_if!{ let inner_termios = unsafe { termios.get_libc_termios_mut() }; let res = unsafe { libc::cfsetspeed(inner_termios, baud.into() as libc::speed_t) }; termios.update_wrapper(); - Errno::result(res).map(drop) + Errno::result(res).map(|_| ()) } } else { /// Get input baud rate (see @@ -980,7 +980,7 @@ cfg_if!{ let inner_termios = unsafe { termios.get_libc_termios_mut() }; let res = unsafe { libc::cfsetispeed(inner_termios, baud as libc::speed_t) }; termios.update_wrapper(); - Errno::result(res).map(drop) + Errno::result(res).map(|_| ()) } /// Set output baud rate (see @@ -991,7 +991,7 @@ cfg_if!{ let inner_termios = unsafe { termios.get_libc_termios_mut() }; let res = unsafe { libc::cfsetospeed(inner_termios, baud as libc::speed_t) }; termios.update_wrapper(); - Errno::result(res).map(drop) + Errno::result(res).map(|_| ()) } /// Set both the input and output baud rates (see @@ -1003,7 +1003,7 @@ cfg_if!{ let inner_termios = unsafe { termios.get_libc_termios_mut() }; let res = unsafe { libc::cfsetspeed(inner_termios, baud as libc::speed_t) }; termios.update_wrapper(); - Errno::result(res).map(drop) + Errno::result(res).map(|_| ()) } } } @@ -1046,13 +1046,13 @@ pub fn tcgetattr(fd: RawFd) -> Result { /// *any* of the parameters were successfully set, not only if all were set successfully. pub fn tcsetattr(fd: RawFd, actions: SetArg, termios: &Termios) -> Result<()> { let inner_termios = termios.get_libc_termios(); - Errno::result(unsafe { libc::tcsetattr(fd, actions as c_int, &*inner_termios) }).map(drop) + Errno::result(unsafe { libc::tcsetattr(fd, actions as c_int, &*inner_termios) }).map(|_| ()) } /// Block until all output data is written (see /// [tcdrain(3p)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcdrain.html)). pub fn tcdrain(fd: RawFd) -> Result<()> { - Errno::result(unsafe { libc::tcdrain(fd) }).map(drop) + Errno::result(unsafe { libc::tcdrain(fd) }).map(|_| ()) } /// Suspend or resume the transmission or reception of data (see @@ -1061,7 +1061,7 @@ pub fn tcdrain(fd: RawFd) -> Result<()> { /// `tcflow()` suspends of resumes the transmission or reception of data for the given port /// depending on the value of `action`. pub fn tcflow(fd: RawFd, action: FlowArg) -> Result<()> { - Errno::result(unsafe { libc::tcflow(fd, action as c_int) }).map(drop) + Errno::result(unsafe { libc::tcflow(fd, action as c_int) }).map(|_| ()) } /// Discard data in the output or input queue (see @@ -1070,7 +1070,7 @@ pub fn tcflow(fd: RawFd, action: FlowArg) -> Result<()> { /// `tcflush()` will discard data for a terminal port in the input queue, output queue, or both /// depending on the value of `action`. pub fn tcflush(fd: RawFd, action: FlushArg) -> Result<()> { - Errno::result(unsafe { libc::tcflush(fd, action as c_int) }).map(drop) + Errno::result(unsafe { libc::tcflush(fd, action as c_int) }).map(|_| ()) } /// Send a break for a specific duration (see @@ -1079,7 +1079,7 @@ pub fn tcflush(fd: RawFd, action: FlushArg) -> Result<()> { /// When using asynchronous data transmission `tcsendbreak()` will transmit a continuous stream /// of zero-valued bits for an implementation-defined duration. pub fn tcsendbreak(fd: RawFd, duration: c_int) -> Result<()> { - Errno::result(unsafe { libc::tcsendbreak(fd, duration) }).map(drop) + Errno::result(unsafe { libc::tcsendbreak(fd, duration) }).map(|_| ()) } /// Get the session controlled by the given terminal (see -- cgit v1.2.3