Use matches! in examples.

This commit is contained in:
Stephen Chung
2020-03-14 23:40:30 +08:00
parent b9e4040635
commit 6e076c409d
6 changed files with 98 additions and 84 deletions

View File

@@ -62,10 +62,11 @@ fn main() {
match input.as_str().trim() {
"exit" | "quit" => break, // quit
"ast" => {
// print the last AST
match &ast {
Some(ast) => println!("{:#?}", ast),
None => println!("()"),
if matches!(&ast, Some(_)) {
// print the last AST
println!("{:#?}", ast.as_ref().unwrap());
} else {
println!("()");
}
continue;
}