Announcing Rust 1.79.0 (blog.rust-lang.org)
from snaggen@programming.dev to rust@programming.dev on 13 Jun 2024 17:24
https://programming.dev/post/15477009

#rust

threaded - newest

BatmanAoD@programming.dev on 13 Jun 2024 19:21 next collapse

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. play.rust-lang.org/?version=stable&mode=debug&edi…

calcopiritus@lemmy.world on 14 Jun 2024 13:25 collapse

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

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

taladar@sh.itjust.works on 14 Jun 2024 13:38 collapse

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).