3 ms·
Thanks, that is very clear. Think Rust differs enough that it's a bit hard for me to draw direct comparisons with my primary languages, but with the emphasis o
by magicalhippo 6y ago
Thanks, that is very clear.
Think Rust differs enough that it's a bit hard for me to draw direct comparisons with my primary languages, but with the emphasis on interfaces like that it does seem like a nicer way to implement extension methods.
- smt1 6y agoHere is some nuance with Rust's OOP relative to java/go/c++: https://stevedonovan.github.io/rust-gentle-intro/object-orientation.html https://stevedonovan.github.io/rust-gentle-intro/object-orie... If you know haskell, Rust's traits are very similar to type classes, except it also has c++-like generics (templates) and is primarily expression-based like ocaml. traits vs haskell type classes: trait -> class struct -> data instance -> impl
- qznc 6y agoIf you are used to Java: It's like making a class implementing an additional interface from the outside. class MyEntity { RenderingCache cache; } now MyEntity implements Drawable { void draw(Canvas canvas) { this.cache.draw_cached(canvas ...); } }