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
Music Theory
Aug 7, 2013

Avatar by Garden Walker

ploots posted:

the biggest thing Rust has over C/C++ is cargo and it's not even close

if i never have to touch make, cmake, qmake, qtcreator, conan, ninja, ant/maven for some godforsaken reason, autotools, or an msvc project again i'll die happy

This, 1,000,000%. Cargo isn't perfect, but I will never take any new language seriously that doesn't try to nail down early a standard build system at least as good as it.

Adbot
ADBOT LOVES YOU

Music Theory
Aug 7, 2013

Avatar by Garden Walker
Nah, I think it's fine. You use dyn if you have a structure or a function whose input/stored type can vary at runtime.

Ex. If you want to store a bunch of things that implement a trait, and those things may be of different types, you'd use a Vec<Box<dyn Foo>>. (The Box is required because Vecs store data in a contiguous array, and the sizes of the dyn Foo's may vary.)

Music Theory fucked around with this message at 17:58 on Jan 14, 2023

Music Theory
Aug 7, 2013

Avatar by Garden Walker

gonadic io posted:

It being nested is a bit annoying. I've made fake little structs like
code:
TestSubClass { parent: Option<Whatever>,  fields: Vec<(String, IvySort)> }
before, slap an Into impl in there and you can use it for your tests. But it being inside the enum variant means you have to still have an explicit match in there or at least make some test function that contains one. Also you'll want to use the `fail` macro instead of just `panic` in your tests.

IIRC you can do something like let Some(foo) = bar else { todo!() }; for slightly clearer code than a whole match.

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