Skip to content

Instantly share code, notes, and snippets.

@ssbr
Created June 8, 2013 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssbr/5736109 to your computer and use it in GitHub Desktop.
Save ssbr/5736109 to your computer and use it in GitHub Desktop.
use core::io;
pub enum MyType {
A, B
}
impl MyType {
pub fn switch(&mut self) {
*self = match *self {
A => B,
B => A,
}
}
}
pub fn main() {
let mut x = A;
x.switch();
io::println(match x {
A => ~"A",
B => ~"B",
});
// outputs "B"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment