42
submitted 3 weeks ago by tmpod@lemmy.pt to c/rust@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] tmpod@lemmy.pt 4 points 2 weeks ago

The two biggest things are lifetime extensions and inline consts. Both will allow you to write more concise code and, in the case of lifetime extensions, may help eliminate some bugs, since you won't need to work around that limitation anymore.

[-] Ephera@lemmy.ml 2 points 2 weeks ago

Yeah, I'm imagining, I've run into these problems in the past and then the compiler told me to do it differently and so I did. I'm definitely glad that such unobvious behavior is being reduced, I just probably won't realize until I'm writing similar code the next time and the compiler does not complain.

[-] tmpod@lemmy.pt 2 points 2 weeks ago

Yeah exactly! It's a great case of "invisible" improvements.

[-] TehPers@beehaw.org 1 points 2 weeks ago* (last edited 2 weeks ago)

Inline consts also let you perform static assertions, like asserting a type parameter is not a zero-sized type, or a const generic is non-zero. This is actually pretty huge since some checks can be moved from runtime to compile time (not a lot of checks, but some that were difficult or impossible to do at compile time before).

this post was submitted on 13 Jun 2024
42 points (97.7% liked)

Rust Programming

7734 readers
3 users here now

founded 5 years ago
MODERATORS