News for hackers. Stuff that matters.
Re:A review after using Rust on embedded in production for o... by fredrikholm on Monday October 14, 2024 @10:29AM (#41837885)
I've gotten far with type switching on an interface that amounts to a single function that does nothing.

Unfortunately it does nothing in terms of exhaustiveness, but it effectively gives you sum types which IME are so, so much easier to work with than state pattern or other inject-an-object-abstractions. Not having to design an API (that later leaks) is rewarding enough.

It's strangely efficient as well. I've experimented with implementing sum types via tagged C-style unions and at every (ad hoc, micro) benchmark I've tried them against, type switching on an interface comes out on top.

Re:A review after using Rust on embedded in production for o... by pdimitar on Monday October 14, 2024 @10:33AM (#41837914)
Can you point me at an article that demonstrates Golang type switching? Does not ring bell at the moment for me so I'd love to see the code.
Re:A review after using Rust on embedded in production for o... by assbuttbuttass on Monday October 14, 2024 @10:52AM (#41838093)
Re:A review after using Rust on embedded in production for o... by pdimitar on Monday October 14, 2024 @10:54AM (#41838107)
Thanks, for some reason I never stumbled upon this. Very valuable, I am bookmarking it.