How to understand the ownership principle of struct m here?
⚓ Rust 📅 2025-08-01 👤 surdeus 👁️ 10use anyhow::Result as AnyResult;
#[derive(Debug)]
struct Value(i32);
#[tokio::main]
async fn main() -> AnyResult<()> {
let mut m = Value(1);
async move {
m.0 = 123;
}
.await;
println!("m: {:?}", m); //why output: m: Value(1)
Ok::<_, anyhow::Error>(())
}
Why?
3 posts - 3 participants
🏷️ Rust_feed