Simplify Cursor::lifetime using a question mark

This commit is contained in:
David Tolnay 2022-09-28 22:47:08 -07:00
parent 502968cc68
commit 65ee83a0ad
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -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,
}