this post was submitted on 13 Jun 2024
79 points (98.8% liked)

Rust

6587 readers
78 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 2 points 9 months ago (1 children)

I don't understand what the advantages of const expressions are.

Isn't const { None } the same as just None?

[โ€“] [email protected] 7 points 9 months ago

const expressions are evaluated at compile time and can be used in locations where you would have to otherwise specify a literal (or something that amounts to a named literal like a const value).