Re:Rust 1.17
by saghm on Thursday April 27, 2017 @08:13PM
(#14215929)
Personally, I give closures in Rust to be much less awkward than lambdas in C++. What issues do you have with them?
[ Parent
| on HN ]
It's the combination of the lambdas and the borrowing system. You have to move all resources into them and then you can't use them from anywhere else.
What I mean is, it's not the closures exactly that are the problem. It's just that closures are one of the times it would be really really convenient if you could have multiple mutable references to something. You end up having to use `Rc<RefCell<>>` as described here:
http://gtk-rs.org/tuto/closures#using-non-gtk-rs-object-into...
This is also mentioned in the Tock PDF: https://sing.stanford.edu/site/publications/levy-plos15-tock... in section 3.2. I'm not really sure how they overcame that in Tock. I guess using RefCell?
Anyway it all seems very awkward.
Ah, I see. I think my perspective tends to be outside the norm when it comes to things like this, since I learned Rust before learning C++, so the Rust way feels "natural", for lack of a better word. I find myself wishing I could do things the Rust way in C++ far more often than vice-versa.
Re:Rust 1.17
by steveklabnik on Friday April 28, 2017 @07:34AM
(#14218556)
They invented some new interior mutability things, if you check the recent Tock discussion on HN via search you should see some things, and a link to Reddit about it.