#strings #lexemes

stringy

A tiny Rust crate for generating byte-sized enums that represent a fixed, ordered set of &str data

6 releases

0.2.2 May 10, 2022
0.2.1 May 10, 2022
0.1.2 Feb 19, 2022

#758 in Rust patterns

MIT license

14KB
202 lines

Stringy

A tiny Rust crate for generating byte-sized enums that represent a fixed, ordered set of &str data.

The original motivation for this crate came up while handwriting lexers and parsers.

Features

  • No more boilerplate for associating enums with fixed string literals
  • Encapsulate a set of string literals as their own type
  • Each generated enum has a size of only 1 byte
  • Each generated enum defines a total order on its variants (based on blanket implementation of derived Ord trait) and exposes an interface to iterate across all variants in this order.
  • Generated data comes with modest documentation. In particular, enum variants and relevant associated methods include user-provided data

No runtime deps