What are drop scopes for captured variable in closure?

⚓ rust    📅 2025-05-29    👤 surdeus    👁️ 3      

surdeus

Warning

This post was published 31 days ago. The information described in this article may have changed.

Given a function, or closure, there are drop scopes for:

  • In the case of a block expression, the scope for the block and the expression are the same scope.
fn main(){
    let i = String::from("i");
    let f = move ||{
     println!("{i}");
   };
}

It is unclear what the drop scope of the captured variable i is.

5 posts - 2 participants

Read full topic

🏷️ rust_feed