Merge pull request #270 from k-nasa/fix_clippy_warn

Fix clippy warning
pull/287/head
Yoshua Wuyts 5 years ago committed by GitHub
commit 5f708f3c4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,7 +14,7 @@ use crate::task::blocking;
///
/// [`os::unix::fs::DirBuilderExt`]: ../os/unix/fs/trait.DirBuilderExt.html
/// [`std::fs::DirBuilder`]: https://doc.rust-lang.org/std/fs/struct.DirBuilder.html
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct DirBuilder {
/// Set to `true` if non-existent parent directories should be created.
recursive: bool,

@ -290,6 +290,12 @@ impl OpenOptions {
}
}
impl Default for OpenOptions {
fn default() -> Self {
Self::new()
}
}
cfg_if! {
if #[cfg(feature = "docs")] {
use crate::os::unix::fs::OpenOptionsExt;

@ -117,7 +117,7 @@ impl Write for Stderr {
// Start the operation asynchronously.
*state = State::Busy(blocking::spawn(async move {
let res = std::io::Write::write(&mut inner.stderr, &mut inner.buf);
let res = std::io::Write::write(&mut inner.stderr, &inner.buf);
inner.last_op = Some(Operation::Write(res));
State::Idle(Some(inner))
}));

@ -117,7 +117,7 @@ impl Write for Stdout {
// Start the operation asynchronously.
*state = State::Busy(blocking::spawn(async move {
let res = std::io::Write::write(&mut inner.stdout, &mut inner.buf);
let res = std::io::Write::write(&mut inner.stdout, &inner.buf);
inner.last_op = Some(Operation::Write(res));
State::Idle(Some(inner))
}));

@ -391,14 +391,14 @@ impl UdpSocket {
/// let mdns_addr = Ipv4Addr::new(224, 0, 0, 123);
///
/// let socket = UdpSocket::bind("127.0.0.1:0").await?;
/// socket.join_multicast_v4(&mdns_addr, &interface)?;
/// socket.join_multicast_v4(mdns_addr, interface)?;
/// #
/// # Ok(()) }) }
/// ```
pub fn join_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> {
pub fn join_multicast_v4(&self, multiaddr: Ipv4Addr, interface: Ipv4Addr) -> io::Result<()> {
self.watcher
.get_ref()
.join_multicast_v4(multiaddr, interface)
.join_multicast_v4(&multiaddr, &interface)
}
/// Executes an operation of the `IPV6_ADD_MEMBERSHIP` type.
@ -435,10 +435,10 @@ impl UdpSocket {
/// For more information about this option, see [`join_multicast_v4`].
///
/// [`join_multicast_v4`]: #method.join_multicast_v4
pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> {
pub fn leave_multicast_v4(&self, multiaddr: Ipv4Addr, interface: Ipv4Addr) -> io::Result<()> {
self.watcher
.get_ref()
.leave_multicast_v4(multiaddr, interface)
.leave_multicast_v4(&multiaddr, &interface)
}
/// Executes an operation of the `IPV6_DROP_MEMBERSHIP` type.

@ -36,13 +36,11 @@ where
let next = futures_core::ready!(self.as_mut().stream().poll_next(cx));
match next {
Some(v) => match (self.as_mut().predicate())(&v) {
true => Poll::Ready(Some(v)),
false => {
cx.waker().wake_by_ref();
Poll::Pending
}
},
Some(v) if (self.as_mut().predicate())(&v) => Poll::Ready(Some(v)),
Some(_) => {
cx.waker().wake_by_ref();
Poll::Pending
}
None => Poll::Ready(None),
}
}

@ -36,13 +36,11 @@ where
let item = futures_core::ready!(Pin::new(&mut *self.stream).poll_next(cx));
match item {
Some(v) => match (&mut self.p)(&v) {
true => Poll::Ready(Some(v)),
false => {
cx.waker().wake_by_ref();
Poll::Pending
}
},
Some(v) if (&mut self.p)(&v) => Poll::Ready(Some(v)),
Some(_) => {
cx.waker().wake_by_ref();
Poll::Pending
}
None => Poll::Ready(None),
}
}

@ -38,13 +38,12 @@ where
match next {
Some(v) => match self.as_mut().predicate() {
Some(p) => match p(&v) {
true => (),
false => {
Some(p) => {
if !p(&v) {
*self.as_mut().predicate() = None;
return Poll::Ready(Some(v));
}
},
}
None => return Poll::Ready(Some(v)),
},
None => return Poll::Ready(None),

@ -10,7 +10,7 @@ use crate::future::Future;
use crate::task::{Context, Poll, Waker};
/// Set if the mutex is locked.
const LOCK: usize = 1 << 0;
const LOCK: usize = 1;
/// Set if there are tasks blocked on the mutex.
const BLOCKED: usize = 1 << 1;

@ -10,7 +10,7 @@ use crate::future::Future;
use crate::task::{Context, Poll, Waker};
/// Set if a write lock is held.
const WRITE_LOCK: usize = 1 << 0;
const WRITE_LOCK: usize = 1;
/// Set if there are read operations blocked on the lock.
const BLOCKED_READS: usize = 1 << 1;

@ -69,12 +69,11 @@ where
let future = task_local::add_finalizer(future);
let future = async move {
let res = future.await;
future.await;
trace!("block_on completed", {
parent_id: parent_id,
child_id: child_id,
});
res
};
// Pin the future onto the stack.

@ -135,7 +135,7 @@ fn random(n: u32) -> u32 {
use std::num::Wrapping;
thread_local! {
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1406868647));
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1_406_868_647));
}
RNG.with(|rng| {
@ -152,6 +152,6 @@ fn random(n: u32) -> u32 {
//
// Author: Daniel Lemire
// Source: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
((x.0 as u64).wrapping_mul(n as u64) >> 32) as u32
((u64::from(x.0)).wrapping_mul(u64::from(n)) >> 32) as u32
})
}

@ -4,7 +4,7 @@ use crate::future::Future;
use crate::io;
/// Task builder that configures the settings of a new task.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct Builder {
pub(crate) name: Option<String>,
}

@ -30,7 +30,7 @@ impl Sleepers {
pub fn wait(&self) {
let mut sleep = self.sleep.lock().unwrap();
if self.notified.swap(false, Ordering::SeqCst) == false {
if !self.notified.swap(false, Ordering::SeqCst) {
*sleep += 1;
let _ = self.wake.wait(sleep).unwrap();
}
@ -38,7 +38,7 @@ impl Sleepers {
/// Notifies one thread.
pub fn notify_one(&self) {
if self.notified.load(Ordering::SeqCst) == false {
if !self.notified.load(Ordering::SeqCst) {
let mut sleep = self.sleep.lock().unwrap();
if *sleep > 0 {

@ -122,7 +122,7 @@ impl TaskId {
unsafe { TaskId(NonZeroU64::new_unchecked(id)) }
}
pub(crate) fn as_u64(&self) -> u64 {
pub(crate) fn as_u64(self) -> u64 {
self.0.get()
}
}

Loading…
Cancel
Save