chore: add more test and fix warnings

This commit is contained in:
appflowy
2022-03-16 10:02:37 +08:00
parent 47081f3095
commit b3ed254caf
24 changed files with 318 additions and 132 deletions

View File

@ -65,34 +65,3 @@ where
}
pub type BoxResultFuture<'a, T, E> = BoxFuture<'a, Result<T, E>>;
#[pin_project]
pub struct FutureResultSend<T, E> {
#[pin]
pub fut: Pin<Box<dyn Future<Output = Result<T, E>> + Send>>,
}
impl<T, E> FutureResultSend<T, E> {
pub fn new<F>(f: F) -> Self
where
F: Future<Output = Result<T, E>> + Send + 'static,
{
Self {
fut: Box::pin(async { f.await }),
}
}
}
impl<T, E> Future for FutureResultSend<T, E>
where
T: Send,
E: Debug,
{
type Output = Result<T, E>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.as_mut().project();
let result = ready!(this.fut.poll(cx));
Poll::Ready(result)
}
}