Why Nostr? What is Njump?
2023-01-27 20:12:27

junderwood4649 on Nostr: Rust closures and async blocks can only be referenced using generic trait bounds or ...

Rust closures and async blocks can only be referenced using generic trait bounds or dynamic dispatch.

It seems like there's a pattern in Rust of the APIs with the most magic being the hardest to understand. Especially if they use anonymous structs under the hood.

Someone had two-level nested move closures and the innermost one was FnMut (called more than once) and they tried to move something from the outermost scope.

The problem being, once it goes in the first closure, it becomes an owned member of the outer closure, so you get errors about partial moves when moving into the inner closure.

Not sure how the errors could be made better, but even I couldn't really explain it to my friend without explaining closures in detail and how they work.

Rust is amazing once you get the hang of it, but oh boy does it take a while to get used to some of the oddities.
Author Public Key
npub1435r8npnlq62e9e9fn7vsfjvq0506ly5fvc7rlctnzc7kedrxdtq4mkh2a