Trait FromPythonString

Source
pub trait FromPythonString: Sized {
    // Required methods
    fn from_python_string(s: &str) -> Option<Self>;
    fn unknown() -> Self;

    // Provided method
    fn parse_or_unknown(s: &str) -> Self { ... }
}
Expand description

Helper trait for converting Python string literals to enum variants.

Required Methods§

Source

fn from_python_string(s: &str) -> Option<Self>

Convert a Python operator string to the enum variant.

Source

fn unknown() -> Self

Get the unknown/default variant.

Provided Methods§

Source

fn parse_or_unknown(s: &str) -> Self

Parse from string with fallback to unknown.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§