-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
It would be cool to if it was possible to specify a custom error type for the FromStr implementation.
I think it could either be of the form struct Error; or struct Error(String); where in the latter it would be passed a copy of the string that we attempted to parse.
use thiserror::Error;
use parse_display::FromStr;
#[derive(Debug, Error)]
#[error("expected one of `var_a` or `var_b`, got `{}`", self.0)]
pub struct ParseMyEnumError(String);
#[derive(Display, FromStr, PartialEq, Debug)]
#[display(style = "snake_case", error = ParseMyEnumError)]
enum MyEnum {
VarA,
VarB,
}elpiel, 90-008 and just-be-dev
Metadata
Metadata
Assignees
Labels
No labels