Skip to content

Instantly share code, notes, and snippets.

@SiegeLord
Forked from ooooak/play.rs
Created September 14, 2015 04:30
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 SiegeLord/188b535b2fcff5b3e06b to your computer and use it in GitHub Desktop.
Save SiegeLord/188b535b2fcff5b3e06b 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 {
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