Function rustler_codegen::nif_unit_enum [−][src]
pub fn nif_unit_enum(input: TokenStream) -> TokenStream
Implementation of the NifUnitEnum macro that lets the user annotate an enum with a unit type
that will generate elixir atoms when encoded
#[derive(NifUnitEnum)]
enum UnitEnum {
FooBar,
Baz,
}
An example usage in elixir would look like the following.
test "unit enum transcoder" do
assert :foo_bar == RustlerTest.unit_enum_echo(:foo_bar)
assert :baz == RustlerTest.unit_enum_echo(:baz)
assert :invalid_variant == RustlerTest.unit_enum_echo(:somethingelse)
end
Note that the :invalid_variant atom is returned if the user tries to encode something
that isn't in the Rust enum.