Skip to main content

parse_enum

Function parse_enum 

Source
pub fn parse_enum<E>(input: &str, param: &str) -> PyResult<E>
where E: FromStr<Err = ParseError> + IntoEnumIterator + ToString,
Expand description

Converts a raw string to the enum E, returning a nicely-formatted PyValueError if the string does not match any variant.

The helper is aimed at Python-exposed functions that still accept plain &str parameters internally: call parse_enum instead of writing repetitive str::parse() + error-formatting logic yourself.

ยงErrors

Returns an error if input does not match any known variant of E.