more-convert: more convert utilities
This crate provides utilities for convert
Usage
more-convert provides a derive macro
EnumReprautomatically implementsTryFromandIntofor enums- Ideal for managing Type, etc.
- Example: test code
Convertautomatically implementsFromorIntofor named structs- Leave the very cumbersome From and Into implementations to us!
- Example From: from's test code
- Example Into: into's test code
Example
EnumRepr
- enum_attributes
- serde: automatically implements
serde::Serializeandserde::Deserialize
- serde: automatically implements
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
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)
use EnumName;
assert_eq!;
assert_eq!;
License
Licensed under