Follow

😭 The borrow checker is no pushover. Brain turning to goo trying to figure out how to tie the lifetime of this channel sender to an Arc of a callback closure.

· · Web · 2 · 2 · 5

@mauve Don't be afraid to `clone()` stuff if that works. Only torture yourself with fancy lifetimes later if perf is bad.

@fabrice Yeah I tried to clone it and shove it into Box/Arc.

@mauve it's possible the `move` keyword could help, and it's not always obvious when you need to use it.

Often when I make a closure that needs to send something I will move the sender into the closure using this keyword. Some examples in the doc page:

doc.rust-lang.org/std/keyword.

@coy I haven't come across this before, ty. I'll try it out in the morning. 🙇

@coy This was exactly what I needed! thank you so much 

Sign in to participate in the conversation
Mauvestodon

Escape ship from centralized social media run by Mauve.