Macro rigetti_pyo3::py_wrap_simple_enum
source · macro_rules! py_wrap_simple_enum {
(
$(#[$meta: meta])*
$name: ident($rs_inner: ident) $(as $py_class: literal)? {
$($variant_name: ident),+
}
) => { ... };
}Expand description
Wrap an enum containing only unit variants.
Implements
- Conversion between Rust and Python types (also converting from references to each)
Macro Inputs
$variant_name: comma-separated list of variant names on the Rust enum. Required because there is no way to do reflection to programmatically find them.- See also
py_wrap_type.
Example
use rigetti_pyo3::py_wrap_simple_enum;
#[derive(Copy, Clone)]
pub enum RustEnum {
Foo,
Bar,
}
py_wrap_simple_enum! {
PyEnum(RustEnum) {
Foo,
Bar
}
}