3 ms·
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?
by gnuvince 12y ago
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?
- jdpage 12y agoRust 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).
- bjz_ 12y agoThis 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.
- Sonata 12y agoThis 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.