Issues with `core::future::Future` implementation causing unexpected runtime behavior in async Rust
I'm sure I'm missing something obvious here, but I've encountered a strange issue with I'm learning this framework and I'm relatively new to this, so bear with me... I'm stuck on something that should probably be simple... I'm trying to implement a simple asynchronous function using the `async`/`await` syntax in Rust, but I'm encountering some unexpected runtime behavior when using the `core::future::Future` trait. My goal is to have a function that returns a future which, when awaited, will perform a computation and return a result. However, I'm observing that my future is not resolving as expected. Here's a simplified version of my code: ```rust use core::future::Future; use core::pin::Pin; use core::task::{Context, Poll}; use std::task::Waker; struct MyFuture { value: i32, state: State, } enum State { Ready, Pending, } impl Future for MyFuture { type Output = i32; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let this = self.get_mut(); match this.state { State::Ready => Poll::Ready(this.value), State::Pending => { // Waker not being called here leads to the future never resolving cx.waker().wake_by_ref(); Poll::Pending } } } } async fn compute() -> i32 { MyFuture { value: 42, state: State::Pending }. } fn main() { let result = tokio::runtime::Runtime::new().unwrap().block_on(compute()); println!("Result: {}", result); } ``` I expect this to print `Result: 42`, but instead, I get no output or, at times, the application hangs indefinitely. I've tried changing the state management and ensuring I'm calling `cx.waker().wake_by_ref()` properly, but it still doesn't resolve correctly. Is there a specific reason why my future might not be resolving? Have I missed any key details in implementing the `Future` trait? I'm using Rust 1.68.0 and the Tokio runtime. Any insights would be greatly appreciated. I'm working on a application that needs to handle this. How would you solve this? This is part of a larger service I'm building. I'm developing on Windows 11 with Rust. Any examples would be super helpful. This is part of a larger REST API I'm building. Any suggestions would be helpful. I'm developing on Ubuntu 22.04 with Rust. Thanks in advance! My team is using Rust for this service. Thanks for any help you can provide!