Announcing Rust 1.79.0 | Rust Blog
https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html
Empowering everyone to build reliable and efficient software.
https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html
Empowering everyone to build reliable and efficient software.
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 Some
variant.
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
I don't understand what the advantages of const expressions are.
Isn't const { None }
the same as just None
?
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).