Re:Purging proc from Rust
by gnuvince on Wednesday November 26, 2014 @08:59PM
(#8665644)
So does Rust still "have closures" or are they now just a specific implementation of a trait? Are there other features that could be implemented as traits?
[ Parent
| on HN ]
Rust has closures, and they are just a specific implementation of a trait.
Many fundamental concepts in Rust, including arithmetic, comparisons, sendability, and smart pointers are formally traits (though the compiler may treat some of them specially, particularly arithmetic and comparisons).
This has been a common theme through Rusts's history. Things that were baked-in language constructs have gradually migrated to become library things with sugar enabled via traits. This is leading to towards a very simple, extensible language.
This is something which really excites me about Rust. Having constructs as fundamental as function application extensible via traits reminds me of Python's magic methods, but without the runtime overhead.