enumizer

Crates.ioenumizer
lib.rsenumizer
version0.1.2
created_at2025-12-11 16:58:12.326318+00
updated_at2025-12-21 07:57:01.731973+00
descriptionsimple macros for generating enums that are equivalent and convertible to standard library enums
homepage
repositoryhttps://github.com/nihohit/enumizer
max_upload_size
id1980134
size33,644
Shachar Langbeheim (nihohit)

documentation

https://docs.rs/enumizer/latest/enumizer

README

This crate provides simple macros for generating enums that are equivalent and convertible to standard library enums, with user-chosen variant names, in order to increase code legibility. So alias_option!(Value, Found, Searching); becomes

enum Value<T> {
  Found(T),
  Searching
}

and alias_result!(Response, Success, Failure); becomes

enum Response<T,U> {
  Success(T),
  Failure(U)
}

and the generated types have all equivalent functions is_found_and (or most, depending on whether we implemented them yet or not :) ). That is, if Option<T> has is_some_and, Value<T> has is_found_and. And if your codebase requires actual Result or Option types, just use into - we implement From<Option/Result> and Into<Option/Result>.

Commit count: 0

cargo fmt