strum-lite

Crates.iostrum-lite
lib.rsstrum-lite
version0.1.1
created_at2025-03-29 17:48:59.48714+00
updated_at2025-03-29 18:08:52.058435+00
descriptionLightweight declarative macro for sets of strings.
homepagehttps://crates.io/crates/strum-lite
repositoryhttps://github.com/aatifsyed/strum-lite
max_upload_size
id1611482
size12,097
Aatif Syed (aatifsyed)

documentation

https://docs.rs/strum-lite

README

Lightweight declarative macro for sets of strings.

strum_lite::strum! {
    pub enum Casing {
        Kebab = "kebab-case",
        ScreamingSnake = "SCREAMING_SNAKE",
    }
}

Features

  • Implements FromStr and Display.
  • Attributes (docs, #[derive(..)]s) are passed through to the definition and variants.
  • Aliases are supported.
  • Custom enum discriminants are passed through.
  • Generated code is #![no_std].
  • The generated FromStr::Err provides a helpful error message.
  • You may ask for a custom error type rather than using this crate's [ParseError].
strum_lite::with_error! {
    #[derive(Default)]
    #[repr(u8)]
    pub enum Casing {
        Kebab = "kebab-case" | "kebab" = 1,
        #[default]
        ScreamingSnake = "SCREAMING_SNAKE" = 1 + 2,
    }
    throws
    #[derive(Clone, Copy)]
    ParseCasingError;
}
Commit count: 8

cargo fmt