Skip to content

Instantly share code, notes, and snippets.

@ooooak
Last active September 14, 2015 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ooooak/ef27c78b568f3fea6ce0 to your computer and use it in GitHub Desktop.
Save ooooak/ef27c78b568f3fea6ce0 to your computer and use it in GitHub Desktop.
#[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.iter() {
let s = match x {
Lx::Str(c) => c,
Lx::Int(c) => c,
Lx::Keyword(c) => c,
_ => "".to_string(),
};
println!("{:?}", s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment