From 9fd80ff6d18fd0a9435c7252e22b59aa0075f6ca Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Sat, 30 Sep 2023 01:43:20 -0400 Subject: [PATCH] add const_ranges iterator --- src/scopeck.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/scopeck.rs b/src/scopeck.rs index d236c92..24d77b1 100644 --- a/src/scopeck.rs +++ b/src/scopeck.rs @@ -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> + '_ { + (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 {