Skip to main content

SetVariant

Derive Macro SetVariant 

Source
#[derive(SetVariant)]
Expand description

ยงExample

#[derive(SetVariant)]
enum MyEnum {
  Foo,
  Bar,
  Baz(String),
}

adds

impl MyEnum {
  pub fn set_foo(&mut self) -> &mut Self {
    *self = Self::Foo;

    self
  }

  pub fn set_bar(&mut self) -> &mut Self {
    *self = Self::Bar;

    self
  }
}