3 ms·
Wait... hmm... now I'm going to have to track down some code where I did this trick and figure out why or if I was just being stupid.
by gpm 8y ago
Wait... hmm... now I'm going to have to track down some code where I did this trick and figure out why or if I was just being stupid.
- steveklabnik 8y agoIt’s cool! In general, the default is “rust tries to capture each thing the way it needs to be” and you can use move to override that. Sometimes, you do have to do what you wrote, at least in theory. I’ve never actually had to.
- chrismorgan 8y agoIf your closures need to be 'static, it’s common in my experience to need to use `move`, and thus to need to clone types like Rc<T>. It depends on whether you’re dealing with Fn, FnMut or FnOnce, too.