4 ms·
Yea for sure, it’s a lot like swift being protocol oriented too. It’s a major paradigm shift I have to enforce in my head manually still at this point tho
by rhodysurf 5y ago
Yea for sure, it’s a lot like swift being protocol oriented too. It’s a major paradigm shift I have to enforce in my head manually still at this point tho
- terhechte 5y agoNote that you can do Swift's protocol oriented programming / portocol extensions in Rust, too: trait Test { fn value(&self) -> i32; } impl dyn Test { fn multiplied(&self) -> i32 { self.value() * 2 } }
- Yoric 5y agoWhat does `impl dyn` mean, exactly? That this only works for trait objects?
- ComputerGuru 5y agoThat it works for any type implementing the trait, via vtables. Otherwise, it’s a method specific to the particular type implementing the trait (a concrete implementation but distinct to the specific impl).