mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
20 lines
314 B
Rust
20 lines
314 B
Rust
//@ run-pass
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
enum Expression {
|
|
Dummy,
|
|
Add(Box<Expression>),
|
|
}
|
|
|
|
use Expression::*;
|
|
|
|
fn simplify(exp: Expression) -> Expression {
|
|
match exp {
|
|
Add(n) => *n.clone(),
|
|
_ => Dummy
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
assert_eq!(simplify(Add(Box::new(Dummy))), Dummy);
|
|
}
|