strum
strum copied to clipboard
Useful changes to `EnumString`
- Added support for enums that consuming strings they have parsed from.
- Changed behaviour to derive
From
trait instead ofTryFrom
when default variant is defined(TryFrom
'll be defined automatically withInfallible
as error type).
[!NOTE]
Maybe a breaking change, because error type ofTryFrom
trait is changed fromParseError
toInfallible
. Enums that consuming strings was leading to compiler error, so there's no breaking change in that part
Changes usage example:
#[derive(Debug, Eq, PartialEq, EnumString)]
#[strum(serialize_all = "UPPERCASE")]
enum HttpMethod<'a> {
Get,
Post,
#[strum(default)]
Unrecognized(&'a str),
}