fast_enum_conversion

Crates.iofast_enum_conversion
lib.rsfast_enum_conversion
version0.1.0
sourcesrc
created_at2024-01-18 12:21:45.972199
updated_at2024-01-18 12:21:45.972199
descriptionZerocost conversion between enums
homepage
repositoryhttps://github.com/yasuo-ozu/fast_enum_conversion
max_upload_size
id1104147
size8,164
yozu (yasuo-ozu)

documentation

README

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:

  • The [std::mem::Discriminant] of them are equal.
  • The fields has same offsets.
  • Have consistent memory layouts.
Commit count: 0

cargo fmt