]> git.lizzy.rs Git - rust.git/commitdiff
Change to add 1 if non zero shift
authorEdwin Cheng <edwin0cheng@gmail.com>
Mon, 4 Nov 2019 17:16:06 +0000 (01:16 +0800)
committerEdwin Cheng <edwin0cheng@gmail.com>
Mon, 4 Nov 2019 17:16:06 +0000 (01:16 +0800)
crates/ra_mbe/src/lib.rs

index b92312d5276aa0c838cadd2bd176e21e60f080b8..15f000175559d8581c3cfed09e7b16f91e71d641 100644 (file)
@@ -108,7 +108,7 @@ pub fn parse(tt: &tt::Subtree) -> Result<MacroRules, ParseError> {
 
         // Note that TokenId is started from zero,
         // We have to add 1 to prevent duplication.
-        let shift = max_id(tt).unwrap_or(0) + 1;
+        let shift = max_id(tt).map_or(0, |it| it + 1);
         Ok(MacroRules { rules, shift })
     }