-
-
Save SiegeLord/188b535b2fcff5b3e06b to your computer and use it in GitHub Desktop.
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
#[derive(Debug)] | |
enum Lx { | |
Str(String), | |
Int(String), | |
Keyword(String), | |
LxUnk(char), | |
} | |
fn main() { | |
let mut v: Vec<Lx> = vec![]; | |
v.push(Lx::Str("test".to_string())); | |
v.push(Lx::Int("124".to_string())); | |
v.push(Lx::Keyword("print".to_string())); | |
v.push(Lx::Str("test".to_string())); | |
for x in &v { | |
let s = match *x { | |
Lx::Str(ref c) => &c[..], | |
Lx::Int(ref c) => &c[..], | |
Lx::Keyword(ref c) => &c[..], | |
_ => "", | |
}; | |
println!("{:?}", s); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment