std 中的 Future trait

版本新特性 / Rust 1.36

// *** 以前 ***
// 这个 trait 过去位于外部的 futures crate 中,
// 它的各个版本使异步库彼此不兼容

// *** 在 1.36 版本中 ***
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

struct Ready(i32);

impl Future for Ready {
    type Output = i32;
    fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<i32> {
        Poll::Ready(self.0)
    }
}