Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ad566b7

Browse files
committed
Tweak Cursor::next_with_spacing.
This makes it more like `CursorRef::next_with_spacing`. There is no performance effect, just a consistency improvement.
1 parent 8305398 commit ad566b7

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,10 @@ impl Cursor {
586586
}
587587

588588
pub fn next_with_spacing(&mut self) -> Option<TreeAndSpacing> {
589-
if self.index < self.stream.len() {
589+
self.stream.0.get(self.index).map(|tree| {
590590
self.index += 1;
591-
Some(self.stream.0[self.index - 1].clone())
592-
} else {
593-
None
594-
}
591+
tree.clone()
592+
})
595593
}
596594

597595
pub fn index(&self) -> usize {

0 commit comments

Comments
 (0)