Skip to content

Instantly share code, notes, and snippets.

@Ph0enixKM
Created January 16, 2018 18:06
Show Gist options
  • Save Ph0enixKM/4586aa9b167fe7aae7b960fc15527140 to your computer and use it in GitHub Desktop.
Save Ph0enixKM/4586aa9b167fe7aae7b960fc15527140 to your computer and use it in GitHub Desktop.
Rusty Invalid Enum
fn main() {
#![allow(unused_variables)]
#[derive(Debug)]
enum Message {
Quit,
Write(String),
}
impl Message {
fn call(&self) {
// I want to take a value of Write(String)
match &self {
&Write(x) => println!("{:?}", x ),
&Quit => println!("err"),
}
}
}
let m = Message::Write(String::from("hello"));
m.call();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment