diff --git a/src/sys/aio.rs b/src/sys/aio.rs index e204b3dcd3..c529451fa0 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -113,24 +113,24 @@ pub enum Buffer<'a> { impl<'a> Buffer<'a> { /// Return the inner `Bytes`, if any pub fn bytes(&self) -> Option<&Bytes> { - match self { - &Buffer::Bytes(ref x) => Some(x), + match *self { + Buffer::Bytes(ref x) => Some(x), _ => None } } /// Return the inner `BytesMut`, if any pub fn bytes_mut(&self) -> Option<&BytesMut> { - match self { - &Buffer::BytesMut(ref x) => Some(x), + match *self { + Buffer::BytesMut(ref x) => Some(x), _ => None } } /// Is this `Buffer` `None`? pub fn is_none(&self) -> bool { - match self { - &Buffer::None => true, + match *self { + Buffer::None => true, _ => false, } } @@ -858,11 +858,7 @@ pub fn aio_cancel_all(fd: RawFd) -> Result { /// See also /// [`aio_suspend`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_suspend.html) pub fn aio_suspend(list: &[&AioCb], timeout: Option) -> Result<()> { - // We must use transmute because Rust doesn't understand that a pointer to a - // Struct is the same as a pointer to its first element. - let plist = unsafe { - mem::transmute::<&[&AioCb], *const [*const libc::aiocb]>(list) - }; + let plist = list as *const [&AioCb] as *const [*const libc::aiocb]; let p = plist as *const *const libc::aiocb; let timep = match timeout { None => null::(), @@ -917,11 +913,7 @@ pub fn lio_listio(mode: LioMode, list: &[&mut AioCb], sigev_notify: SigevNotify) -> Result<()> { let sigev = SigEvent::new(sigev_notify); let sigevp = &mut sigev.sigevent() as *mut libc::sigevent; - // We must use transmute because Rust doesn't understand that a pointer to a - // Struct is the same as a pointer to its first element. - let plist = unsafe { - mem::transmute::<&[&mut AioCb], *const [*mut libc::aiocb]>(list) - }; + let plist = list as *const [&mut AioCb] as *const [*mut libc::aiocb]; let p = plist as *const *mut libc::aiocb; Errno::result(unsafe { libc::lio_listio(mode as i32, p, list.len() as i32, sigevp)