Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::future::Future;
- use std::task::{Context, Poll};
- use std::pin::Pin;
- enum State {
- A(i32),
- }
- struct MyFuture {
- rx: Pin<Box<dyn Future<Output=i32> + Send>>,
- state: State,
- }
- impl Future for MyFuture {
- type Output = ();
- fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
- loop {
- match &mut self.state {
- State::A(n) => {
- match Pin::new(&mut self.rx).poll(cx) {
- Poll::Ready(_) => {
- *n = 10; // 只要有这句就报错
- }
- _ => unimplemented!(),
- }
- // *n = 10; // 放这里一样报错
- },
- }
- }
- }
- }
- fn main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement