76
Announcing Rust 1.79.0 (blog.rust-lang.org)
submitted 1 month ago by [email protected] to c/[email protected]
top 3 comments
sorted by: hot top controversial new old
[-] [email protected] 10 points 1 month ago* (last edited 1 month ago)

How does the const { None } example type-inference work? The size of the option type can't be known without knowing the type of the Somevariant.

Edit: aha, it doesn't work as-is. It needs to infer the type of elements of foo from usage. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=05a95c592626b6935ae812527aa6bbc6

[-] [email protected] 2 points 1 month ago

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

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

[-] taladar 7 points 1 month 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).

this post was submitted on 13 Jun 2024
76 points (98.7% liked)

Rust

5463 readers
2 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 1 year ago
MODERATORS