Crates.io | enum-extract-macro |
lib.rs | enum-extract-macro |
version | 0.1.1 |
source | src |
created_at | 2023-12-28 18:38:19.683106 |
updated_at | 2023-12-30 02:17:04.032464 |
description | A derive macro for extracting enum variants into their own types. |
homepage | https://github.com/James-LG/enum-extract |
repository | https://github.com/James-LG/enum-extract |
max_upload_size | |
id | 1082603 |
size | 59,315 |
A deriving proc-macro that generates functions to the inner members of the enum.
This is a heavily modified fork of enum-as-inner. Some of the key differences are listed below:
as_[variant]
, into_[variant]
and as_[variant]_mut
methods return a Result that can contain a concrete error type EnumExtractError
.
expected {expected}, got {actual}
,
so that you have a place to start troubleshooting rather than calling unwrap
on an Option
,
or repeatedly writing better error messages by hand.extract_as_[variant]
, extract_into_[variant]
and extract_as_[variant]_mut
methods,
which panic if the actual variant does not match the expected variant.
EnumExtractError
struct.This project consists of two crates that should be used together. They are separate because crates the export procedural macros can only export procedural macros. They should be treated as a single project, and will therefore be versioned in lock-step.
Provides the EnumExtract
derive macro that can be used on enums to get as_[variant]
functions for each variant,
along with other useful functions.
See the documentation for examples and more details.
Provides the EnumExtractError
used as a return value for the as_[variant]
functions.
See the documentation for examples and more details.