Run fmt and clippy

This commit is contained in:
Gus Caplan
2019-05-28 09:52:44 -05:00
parent dfcaabc738
commit 2cc40a27d2
9 changed files with 84 additions and 64 deletions

View File

@ -1,14 +1,14 @@
use std::fmt;
use std::pin::Pin;
use std::cell::{Cell, RefCell};
use std::sync::Arc;
use std::future::Future;
use std::task::{Poll, Context};
use std::collections::VecDeque;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use futures_util::task::ArcWake;
use futures_util::future::FutureExt;
use futures_channel::oneshot;
use futures_util::future::FutureExt;
use futures_util::task::ArcWake;
use lazy_static::lazy_static;
@ -112,14 +112,12 @@ where
Promise::new(&mut |resolve, reject| {
// TODO change Promise::new to be FnOnce
spawn_local(future.take().unwrap_throw().map(move |val| {
match val {
Ok(val) => {
resolve.call1(&JsValue::undefined(), &val).unwrap_throw();
},
Err(val) => {
reject.call1(&JsValue::undefined(), &val).unwrap_throw();
},
spawn_local(future.take().unwrap_throw().map(move |val| match val {
Ok(val) => {
resolve.call1(&JsValue::undefined(), &val).unwrap_throw();
}
Err(val) => {
reject.call1(&JsValue::undefined(), &val).unwrap_throw();
}
}));
})
@ -147,7 +145,10 @@ where
impl Task {
#[inline]
fn new<F>(future: F) -> Arc<Self> where F: Future<Output = ()> + 'static {
fn new<F>(future: F) -> Arc<Self>
where
F: Future<Output = ()> + 'static,
{
Arc::new(Self {
future: RefCell::new(Some(Box::pin(future))),
is_queued: Cell::new(false),
@ -171,7 +172,6 @@ where
}
}
struct NextTick {
is_spinning: Cell<bool>,
promise: Promise,
@ -180,7 +180,10 @@ where
impl NextTick {
#[inline]
fn new<F>(mut f: F) -> Self where F: FnMut() + 'static {
fn new<F>(mut f: F) -> Self
where
F: FnMut() + 'static,
{
Self {
is_spinning: Cell::new(false),
promise: Promise::resolve(&JsValue::null()),
@ -205,7 +208,6 @@ where
}
}
struct Executor {
// This is a queue of Tasks which will be polled in order
tasks: RefCell<VecDeque<Arc<Task>>>,
@ -265,6 +267,5 @@ where
};
}
ArcWake::wake_by_ref(&Task::new(future));
}