Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
lifg
Dec 4, 2000
<this tag left blank>
Muldoon

Dominoes posted:

My ROT: If you use a `Fn` trait and you get compile errors, prepend `dyn`, If that doesn't work, also wrap it in a box. If you give up, use a `fn` pointer instead.

IMO this is one of the more poorly-designed parts of the lang.

I hate that I’ve been using Rust for a few months now and I have no idea what this means.

Adbot
ADBOT LOVES YOU

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
I’m working with a couple giant RESTful actix apps. I guess if I looked under the hood more I’d see those higher order functions in action.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
Advice on stack overflow is often invalid if it’s more than a couple years old. Library documentation isn’t great, and sometimes there’s just no one (publicly) using the function you’re trying to figure out.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
The Result and Option and match and enum are so good. Everyone talks about the speed and memory management, but for me it’s all about those algebraic data types.

I had to build an SDK in Go a couple weeks ago, and on one hand I like that it doesn’t have null values, but where was my Option?

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
What’s the best practice for storing simple enums in a database? I’ve been manually implementing Display and FromStr to make it easy to convert to and from an SQL text column, but is there a better way?

Adbot
ADBOT LOVES YOU

lifg
Dec 4, 2000
<this tag left blank>
Muldoon

gonadic io posted:

How simple? If there's no (and can never be) any fields in any of the variants, then that's a job for the ol' integer.

Exactly that simple.

I haven’t used enum discriminants.

How do I convert from an integer back to the enum? Google is telling me I need to write a try_from function. Is that correct?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply