Skip to content

Commit

Permalink
Simplify Cursor::lifetime using a question mark
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 29, 2022
1 parent 502968c commit 65ee83a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 65ee83a

Please sign in to comment.