An example of hand-written coroutines 141 Futures module In futures. rs, the first thing we'll do is define a Future trait. It looks as follows: ch07/a-coroutine/src/future. rs pub trait Future { type Output; fn poll(&mut self)-> Poll State<Self::Output>; } If we contrast this with the Future trait in Rust's standard library, you'll see it's very similar, except that we don't take cx: &mut Context<'_> as an argument and we return an enum with a slightly different name just to differentiate it so we don't mix them up: pub trait Future { type Output; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>)-> Poll<Self::Output>; } The next thing we do is to define a Poll State<T> enum : ch07/a-coroutine/src/future. rs pub enum Poll State<T> { Ready(T), Not Ready, } Again, if we compare this to the Poll enum in Rust's standard library, we see that they're practically the same: pub enum Poll<T> { Ready(T), Pending, } For now, this is all we need to get the first iteration of our example up and running. Let's move on to the next file: http. rs.