5 releases (3 breaking)
new 0.4.0 | Nov 18, 2024 |
---|---|
0.3.0 | May 24, 2024 |
0.2.2 | May 23, 2024 |
0.2.0 | Mar 21, 2024 |
0.1.0 | Jan 22, 2024 |
#1342 in Rust patterns
24KB
82 lines
enumcapsulate
Safe casting for newtype enums and their variants.
Traits
The enumcapsulate
crate exports the following traits:
Traits | Functionality |
---|---|
AsVariant |
Provides owned access to the current variant's field. |
AsVariantMut |
Provides mutable borrowed access to the current variant's field. |
AsVariantRef |
Provides borrowed access to the current variant's field. |
Encapsulate |
Umbrella derive macro for AsVariant , AsVariantMut , AsVariantRef , From , FromVariant , IntoVariant , TryInto , VariantDiscriminant , and VariantDowncast |
FromVariant |
Creates an instance of Self from the unambiguous field type of one of its variants. |
IntoVariant |
Returns the current variant's field, consuming self . |
VariantDiscriminant |
Used to obtain an enum variant's discriminant |
VariantDowncast |
Convenience umbrella trait utilizing AsVariant , AsVariantRef , AsVariantMut , and IntoVariant |
Derive macros
The enumcapsulate
crate exports the following corresponding derive macros, if the "derive"
feature is enabled (which is the default):
AsVariant
AsVariantMut
AsVariantRef
Encapsulate
From
FromVariant
IntoVariant
-TryInto
VariantDiscriminant
Documentation
Please refer to the documentation on docs.rs.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct,
and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
License
This project is licensed under the MPL-2.0 – see the LICENSE.md file for details.
Dependencies
~105KB