capture by value class members

No, data members cannot be captured by value. A lambda can capture only two kinds of things: the this pointer, and nonstatic local variables (that is, variables with automatic storage duration). As has been noted by ildjarn in the comments, you can create a local variable with a copy of the value of the data … Read more

How to accept an async function as an argument?

async functions are effectively desugared as returning impl Future. Once you know that, it’s a matter of combining existing Rust techniques to accept a function / closure, resulting in a function with two generic types: use std::future::Future; async fn example<F, Fut>(f: F) where F: FnOnce(i32, i32) -> Fut, Fut: Future<Output = bool>, { f(1, 2).await; … Read more

Is there a way to have a Rust closure that moves only some variables into it?

Yes, it is possible to move only one or some variables into a closure (rather than all or none). Yes, this can be used to “circumvent” reference counting. I found an answer in the documentation of rayon::scope that turns out to be exactly about this problem: ‘Accessing the stack data [from within a scoped threads … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)