Skip to content

Commit 3038141

Browse files
committed
simplify
1 parent 966983c commit 3038141

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

crates/mbe/src/expander/matcher.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -707,31 +707,29 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
707707
let tt_result = match kind {
708708
"ident" => input
709709
.expect_ident()
710-
.map(|ident| Some(tt::Leaf::from(ident.clone()).into()))
710+
.map(|ident| tt::Leaf::from(ident.clone()).into())
711711
.map_err(|()| err!("expected ident")),
712-
"tt" => input.expect_tt().map(Some).map_err(|()| err!()),
713-
"lifetime" => {
714-
input.expect_lifetime().map(Some).map_err(|()| err!("expected lifetime"))
715-
}
712+
"tt" => input.expect_tt().map_err(|()| err!()),
713+
"lifetime" => input.expect_lifetime().map_err(|()| err!("expected lifetime")),
716714
"literal" => {
717715
let neg = input.eat_char('-');
718716
input
719717
.expect_literal()
720718
.map(|literal| {
721719
let lit = literal.clone();
722720
match neg {
723-
None => Some(lit.into()),
724-
Some(neg) => Some(tt::TokenTree::Subtree(tt::Subtree {
721+
None => lit.into(),
722+
Some(neg) => tt::TokenTree::Subtree(tt::Subtree {
725723
delimiter: None,
726724
token_trees: vec![neg, lit.into()],
727-
})),
725+
}),
728726
}
729727
})
730728
.map_err(|()| err!())
731729
}
732730
_ => Err(ExpandError::UnexpectedToken),
733731
};
734-
return tt_result.map(|it| it.map(Fragment::Tokens)).into();
732+
return tt_result.map(|it| Some(Fragment::Tokens(it))).into();
735733
}
736734
};
737735
input.expect_fragment(fragment).map(|it| it.map(Fragment::Tokens))

0 commit comments

Comments
 (0)