this post was submitted on 16 Oct 2024
65 points (97.1% liked)
Rust
5949 readers
1 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Something i didnt know for a long time (even though its mentioned in the book pretty sure) is that enum discriminants work like functions
Not too crazy but its something that blew my mind when i first saw it
Yea it's like when we write
Some(2)
. It's not a function call but a variant of theOption
enum.Enum constructors are functions, this typechecks:
I was a bit apprehensive because rust has like a gazillion different function types but here it seems to work like just any other language with a HM type system.
Woah. That's quite interesting. I didn't know that.