Created
January 16, 2018 18:06
-
-
Save Ph0enixKM/4586aa9b167fe7aae7b960fc15527140 to your computer and use it in GitHub Desktop.
Rusty Invalid Enum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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