little_ferris to RustEnglish · edit-29 hours agoWhat are some mind blowing Rust tricks?message-squaremessage-square26fedilinkarrow-up143arrow-down10file-text
arrow-up143arrow-down1message-squareWhat are some mind blowing Rust tricks?little_ferris to RustEnglish · edit-29 hours agomessage-square26fedilinkfile-text
If we were to create a Rust version of this page for Haskell, what cool programming techniques would you add to it?
minus-squarelittle_ferrisOPlinkfedilinkEnglisharrow-up1·2 hours agoYea it’s like when we writeSome(2). It’s not a function call but a variant of the Option enum.
minus-squarebarsoap@lemm.eelinkfedilinkarrow-up2·2 hours agoEnum constructors are functions, this typechecks: fn foo<T>() { let f: fn(T) -> Option<T> = Some; } 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.
minus-squarelittle_ferrisOPlinkfedilinkEnglisharrow-up1·19 minutes agoWoah. That’s quite interesting. I didn’t know that.
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:
fn foo<T>() { let f: fn(T) -> Option<T> = Some; }
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.