gender is: a boolean, 0, 1, 2, "none", "limited", "full", "line-tables-only", or "line-directives-only"
> The non_exhaustive attribute indicates that a type or variant may have more fields or variants added in the future.
blog.implrust.com/posts/2025/0...
#rustlang
> The non_exhaustive attribute indicates that a type or variant may have more fields or variants added in the future.
blog.implrust.com/posts/2025/0...
#rustlang
- If you mark your enum with non_exhaustive attribute, it enforces users to always use wildcards in match statements
- You can add more variants to your library without breaking users' code; no major version bump required
- If you mark your enum with non_exhaustive attribute, it enforces users to always use wildcards in match statements
- You can add more variants to your library without breaking users' code; no major version bump required
This allows you to add new variants later without breaking existing code.
This attribute forces people to have a _ pattern in their matches that will match any items you add later.
#Rust30by30
This allows you to add new variants later without breaking existing code.
This attribute forces people to have a _ pattern in their matches that will match any items you add later.
#Rust30by30
github.com/rust-lang/ru...
It seems to have the notion of an unsuited type, which is a non-local ADT with private fields or a `non_exhaustive` attribute, and will lint if you use it as a ZST.
github.com/rust-lang/ru...
It seems to have the notion of an unsuited type, which is a non-local ADT with private fields or a `non_exhaustive` attribute, and will lint if you use it as a ZST.
- Let's say we create a library with Menu enum;when you add more variants in the future, it will be a breaking change because users' match statements won't compile
- As library dev, you should bump to next major version (e.g: 1.0.0 to 2.0.0)
- Let's say we create a library with Menu enum;when you add more variants in the future, it will be a breaking change because users' match statements won't compile
- As library dev, you should bump to next major version (e.g: 1.0.0 to 2.0.0)
and the Rust change isn't breaking if the enum is non_exhaustive
and the Rust change isn't breaking if the enum is non_exhaustive
Great for stable APIs!
More details: doc.rust-lang.org/reference/at...
Great for stable APIs!
More details: doc.rust-lang.org/reference/at...
When you might add fields later, this combo prevents direct struct literals, forcing users to use your constructor. Result? You can add fields without breaking existing code.
Example
#rust #rustlang
When you might add fields later, this combo prevents direct struct literals, forcing users to use your constructor. Result? You can add fields without breaking existing code.
Example
#rust #rustlang
We had this for a while in #AzureSDK for #rustlang but found it to cause more friction than worth it to. When all your data fields are pub anyway, forcing a constructor is pointless.
We had this for a while in #AzureSDK for #rustlang but found it to cause more friction than worth it to. When all your data fields are pub anyway, forcing a constructor is pointless.