Skip to content

Commit

Permalink
add const_ranges iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
digama0 committed Sep 30, 2023
1 parent 3957f78 commit 9fd80ff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/scopeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ pub struct VerifyExpr {
pub tail: Box<[ExprFragment]>,
}

impl VerifyExpr {
/// Returns an iterator over runs of constants in the expression,
/// as references into the constant pool.
pub fn const_ranges(&self) -> impl Iterator<Item = Range<usize>> + '_ {
(self.tail.iter().map(|e| &e.prefix))
.chain(std::iter::once(&self.rump))
.cloned()
}
}

/// Representation of a hypothesis in a frame program.
#[derive(Clone, Debug)]
pub enum Hyp {
Expand Down

0 comments on commit 9fd80ff

Please sign in to comment.