From 65ee83a0ad2dd69f503ba85e5a0a49f74c173f68 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 28 Sep 2022 22:47:08 -0700 Subject: [PATCH] Simplify Cursor::lifetime using a question mark --- src/buffer.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index f6667275..d7483d33 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -261,16 +261,12 @@ impl<'a> Cursor<'a> { match self.entry() { Entry::Punct(punct) if punct.as_char() == '\'' && punct.spacing() == Spacing::Joint => { let next = unsafe { self.bump_ignore_group() }; - match next.ident() { - Some((ident, rest)) => { - let lifetime = Lifetime { - apostrophe: punct.span(), - ident, - }; - Some((lifetime, rest)) - } - None => None, - } + let (ident, rest) = next.ident()?; + let lifetime = Lifetime { + apostrophe: punct.span(), + ident, + }; + Some((lifetime, rest)) } _ => None, }