fast-down-gui 0.1.45

超级快的下载器图形化界面
Documentation
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

pub struct ForceSend<F>(pub F);

unsafe impl<F> Send for ForceSend<F> {}

impl<F: Future> Future for ForceSend<F> {
    type Output = F::Output;
    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
        unsafe { self.map_unchecked_mut(|s| &mut s.0).poll(cx) }
    }
}

pub trait ForceSendExt {
    fn force_send(self) -> ForceSend<Self>
    where
        Self: Sized,
    {
        ForceSend(self)
    }
}

impl<F> ForceSendExt for F {
    fn force_send(self) -> ForceSend<Self> {
        ForceSend(self)
    }
}