Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Drop order of local variables in async fn
In the code below, let's say we're awaiting a()
and abort the future returned from a()
by calling handle.abort()
.
In this case, is there a defined guarantee regarding the drop order of local variables, data
and my_fut
?
```rust
async fn a() {
let data = get_data();
let my_fut = fut(&data);
my_fut.await; // cancelled here
}
fn fut(data: &MyData) -> MyFuture<'_> {
MyFuture { data }
}
fn main() {
let handle: JoinHandle<()> = tokio::spawn(a());
handle.abort(); // cancels the task;
}
2 posts - 2 participants
🏷️ Rust_feed