3 ms·
Thank you so much! that's very interesting.
by sodality2 5y ago
Thank you so much! that's very interesting.
- Arnavion 5y agoIf the problem is as pornel described, you can work around it by creating the borrow of self.whatever outside the closure. Instead of: foo(|| { bar(&self.whatever); }); ... do: let whatever = &self.whatever; foo(|| { bar(whatever); }); To avoid leaking `whatever` into the scope, there's an idiom that looks like this: foo({ let whatever = &self.whatever; || { bar(whatever); } });
- sodality2 5y agoYeah that's what I've had to do, it just seemed like an oversight tbh. Maybe the idea is to not keep the entire GUI state in a single object though, but it's the one time learning rust that I thought "hey that doesn't make sense". which really speaks to Rust's strengths, rather than its weaknesses. Can't wait for 2021