Hacker News new | ask | show | jobs
by jokethrowaway 1926 days ago
Even if you didn't have Output Pin, couldn't you just declare a sum type?

enum MyPin { P0, P1 }

Edit: feel free to ignore, read your answer somewhere else about this

You would then have to pattern match when you read the value but I don't see a reason to reach for macros or anything more complicated.

That said, really enjoyed the read (and I'll definitely try zig at some point, if only for the speed / compile experience), even if my experience with Rust didn't match yours; my background is a bit different though, I worked with C++ and Haskell in the past, which definitely made rust feel almost natural. Overall I'd say that the compiler helps me not to keep a lot of rust syntax in my mind and just try things until it works

1 comments

As someone who has gone from python -> c++ -> rust I'll agree with you here. Rust feels a lot more natural than c++ to get your ideas into code.