Skip to content

Commit

Permalink
aio: more Clippy cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
asomers committed Jan 14, 2018
1 parent 876b54e commit bb46a99
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/sys/aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -858,11 +858,7 @@ pub fn aio_cancel_all(fd: RawFd) -> Result<AioCancelStat> {
/// See also
/// [`aio_suspend`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_suspend.html)
pub fn aio_suspend(list: &[&AioCb], timeout: Option<TimeSpec>) -> 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::<libc::timespec>(),
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bb46a99

Please sign in to comment.