Skip to content

regexident/enumcapsulate

Repository files navigation

enumcapsulate

Crates.io Crates.io Crates.io docs.rs

Safe casting for newtype enums and their variants.


Traits

The enumcapsulate crate exports the following traits:

Traits Functionality
AsVariant Umbrella derive macro for AsVariantRef, and AsVariantMut
AsVariantMut Used to do a cheap mutable-to-mutable reference conversion between an outer enum's and its inner variant's type
AsVariantRef Used to do a cheap reference-to-reference reference conversion between an outer enum's and its inner variant's type
Encapsulate Umbrella derive macro for AsVariantMut, AsVariantRef, From, FromVariant, IntoVariant, IsVariant, TryInto, VariantDiscriminant, and VariantDowncast AsVariantMut
FromVariant Used to do variant-to-enum conversions between an outer enum's and its inner variant's type
IntoVariant Used to do enum-to-variant conversions between an outer enum's and its inner variant's type
IsVariant Used to check type of an enum's inner variant's type
VariantDiscriminant Used to obtain an enum variant's discriminant
VariantDowncast Convenience umbrella trait utilizing AsVariantRef, AsVariantMut, and IntoVariant

Derive macros

as well as the following corresponding derive macros via enumcapsulate::derive::*:

  • AsVariant
  • AsVariantMut
  • AsVariantRef
  • Encapsulate
  • From
  • FromVariant
  • IntoVariant
  • IsVariant
  • 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.

About

Safe casting for newtype enums and their variants

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages