Chisle
코딩 에이전트 플러그인, 20개 실시간 작업에서 기본 모델 52% 활용, 간결한 페르소나와 출력 압축 제공
enum에 커스텀 파생을 추가하는 작은 Rust 라이브러리입니다
A small rust library for adding custom derives to enums
개발 도구RustGitHub @Peternator7직접 설치운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
메이커가 쓴 소개는 위의 한 줄이 전부입니다. 더 자세한 내용은 저장소 README에서 읽을 수 있습니다. 저장소 README ↗
README 전체를 불러오는 중입니다.
README 전문 보기 ↗Strum is a set of macros and traits for working with enums and strings easier in Rust.
Strum is currently compatible with versions of rustc >= 1.71.1. Pull Requests that improve compatibility with older versions are welcome. The project goal is to support a rust version for at least 2 years after release and even longer is preferred since this project changes slowly.
Import strum and strum_macros into your project by adding the following lines to your Cargo.toml. Strum_macros contains the macros needed to derive all the traits in Strum.
[dependencies]
strum = "0.28"
strum_macros = "0.28"
# You can also use the "derive" feature, and import the macros directly from "strum"
# strum = { version = "0.28", features = ["derive"] }
Strum has implemented the following macros:
| Macro | Description |
|---|---|
| EnumString | Converts strings to enum variants based on their name. |
| Display | Converts enum variants to strings |
| FromRepr | Convert from an integer to an enum. |
| AsRefStr | Implement AsRef<str> for MyEnum |
| IntoStaticStr | Implements From<MyEnum> for &'static str on an enum |
| EnumIter | Creates a new type that iterates of the variants of an enum. |
| EnumProperty | Add custom properties to enum variants. |
| EnumMessage | Add a verbose message to an enum variant. |
| EnumDiscriminants | Generate a new type with only the discriminant names. |
| EnumCount | Add a constant usize equal to the number of variants. |
| VariantArray | Adds an associated VARIANTS constant which is an array of all enum discriminants |
| VariantNames | Adds an associated VARIANTS constant which is an array of discriminant names |
Thanks for your interest in contributing. Bug fixes are always welcome. If you are interested in implementing or adding a macro, please open an issue first to discuss the feature. I have limited bandwidth to review new features.
The project is divided into 3 parts, the traits are in the
/strum folder. The procedural macros are in the /strum_macros folder, and the integration tests are
in /strum_tests. If you are adding additional features to strum or strum_macros, you should make sure
to run the tests and add new integration tests to make sure the features work as expected.
To see the generated code, set the STRUM_DEBUG environment variable before compiling your code.
STRUM_DEBUG=1 will dump all of the generated code for every type. STRUM_DEBUG=YourType will
only dump the code generated on a type named YourType.
Strum is short for STRing enUM because it's a library for augmenting enums with additional information through strings.
Strumming is also a very whimsical motion, much like writing Rust code.