more-convert: more convert utilities
This crate provides utilities for convert
Usage
more-convert provides a derive macro
Convertautomatically implementsFromorIntofor named structs- Leave the very cumbersome From and Into implementations to us!
- more info: doc.rs
EnumReprautomatically implementsTryFromandIntofor enums- Ideal for managing Type, etc.
- more info: doc.rs
EnumNameprovides a method to get the name of the enum variant- Ideal for error (kind) handling, etc.
- more info: doc.rs
Examples
What I write below is what I picked up. I try to keep it up to date in doc.rs, so please look there!
EnumRepr
- enum_attributes
- serde: automatically implements
serde::Serializeandserde::Deserialize
- serde: automatically implements
more info: doc.rs
use EnumRepr;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Convert
- field_attributes
- ignore: skip the field
- rename: rename the field
- map
- map: map of expr
- map_field: map of field
- map_struct: map of struct
more info: doc.rs
use Convert;
let b = B ;
let a: A = b.into;
assert_eq!;
assert_eq!;
more Into examples are here
more From examples are here
EnumName
-
enum_attributes
- rename_all: apply rule to field name
- Possible values: "lowercase", "UPPERCASE", "PascalCase", "camelCase", "snake_case", "SCREAMING_SNAKE_CASE", "kebab-case", "SCREAMING-KEBAB-CASE"
- prefix: add prefix to field name
- suffix: add suffix to field name
- rename_all: apply rule to field name
-
variant_attributes
- rename: rename field (prefix, suffix, and rename_all are not applied)
more info: doc.rs
use EnumName;
assert_eq!;
assert_eq!;
License
Licensed under