Skip to content

Commit

Permalink
Add first speculative pass
Browse files Browse the repository at this point in the history
  • Loading branch information
reknih committed Oct 16, 2023
1 parent 32f6d42 commit b5e395c
Show file tree
Hide file tree
Showing 11 changed files with 578 additions and 202 deletions.
8 changes: 8 additions & 0 deletions src/csl/elem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ impl<T> NonEmptyStack<T> {
Some(mem::replace(&mut self.last, new_last))
}

pub fn get(&self, idx: usize) -> Option<&T> {
if idx == self.head.len() {
Some(&self.last)
} else {
self.head.get(idx)
}
}

/// Drains all elements including and after the given index.
pub fn drain(&mut self, idx: NonZeroUsize) -> impl Iterator<Item = T> + '_ {
let idx = idx.get();
Expand Down
Loading

0 comments on commit b5e395c

Please sign in to comment.