// you need to borrow self as mutable then edit the deref value enum Dir { Left, Right, } impl Dir { fn switch(&mut self) { *self = match *self { Dir::Left => Dir::Right, Dir::Right => Dir::Left, }; } }
// you need to borrow self as mutable then edit the deref value enum Dir { Left, Right, } impl Dir { fn switch(&mut self) { *self = match *self { Dir::Left => Dir::Right, Dir::Right => Dir::Left, }; } }