Simplify if let.

This commit is contained in:
Stephen Chung
2021-12-12 12:33:22 +08:00
parent 3a5495a65c
commit 780c36e675
5 changed files with 32 additions and 36 deletions

View File

@@ -2223,10 +2223,9 @@ impl<'a> Iterator for TokenIterator<'a> {
};
// Run the mapper, if any
let token = if let Some(map_func) = self.token_mapper {
map_func(token, pos, &self.state)
} else {
token
let token = match self.token_mapper {
Some(map_func) => map_func(token, pos, &self.state),
None => token,
};
Some((token, pos))