#enums #conversion #variant #fields #offset #equals #zerocost

macro fast_enum_conversion_macro

Zerocost conversion between enums

1 unstable release

0.1.0 Jan 18, 2024

#36 in #equals


Used in fast_enum_conversion

MIT license

12KB
233 lines

Fast enum conversion

This crate provides zerocost conversion between enums. An enum Src can be converted to another enum Dest when the following satisfies:

  • For each variants of Src, counterparts exist in Dest.

Here, an variant ans its "counterpart" satisfies all of them:

  • Both has the same tag names
  • Fields of both variants are equal. For example, one has structural fields, another should have the same.
  • All corresponding type of Fields are the same.

It performs zerocost conversion when following satisfies for all counterparts:

Dependencies

~1.5MB
~34K SLoC