Re:Functional Language Features in Rust – Iterators and Clos...
by Manishearth on Tuesday March 07, 2017 @06:14PM
(#13816127)
> Answered my question a few paragraphs down. Kudos.
I absolutely love it when a blog post, talk, or docs like these do that.
Especially during talks. Often the speaker will say something and it will immediately pop up questions in my mind which I really really want to ask but of course I should wait till the end. And then they answer it in the next slide. Perfect :)
Re:Functional Language Features in Rust – Iterators and Clos...
by steveklabnik on Tuesday March 07, 2017 @06:06PM
(#13816056)
Thanks!
To answer your last question, not yet. There was an RFC for this, but it was recently postponed; closures rely heavily on traits and we are in the process of re-doing the internals of the trait system. If I remember the reason correctly.
Re:Functional Language Features in Rust – Iterators and Clos...
by eddyb on Tuesday March 07, 2017 @06:33PM
(#13816318)
Indeed, the way you would be generic over generic closures would be "type HRTB" (e.g. F: for<T: Clone> Fn(&T) -> T), which depends on the trait system overhaul, just like ATC.
Re:Functional Language Features in Rust – Iterators and Clos...
by TheCycoONE on Tuesday March 07, 2017 @09:07PM
(#13817208)
The whole new Rust Book is quite well written. It was my first resource when I read it a few months ago and I found it easy to understand everything it covered - even lifetimes which I completely failed to get from the original book or other online resources. I look forward to the rest of the chapters being filled in.
Answered my question a few paragraphs down. Kudos.
Is it possible to write a generic closure? i.e something that would add 1 to any numeric type.