temex 0.10.0

Regex-like temporal expressions for evaluating systems that change over time
Documentation
use std::ops::Range;

/// A TemexMatch represents a single match of a temex in a temex trace.
#[derive(Clone, Debug, PartialEq)]
pub struct TemexMatch {
    pub(crate) start: usize,
    pub(crate) end: usize,
}

impl From<TemexMatch> for Range<usize> {
    fn from(m: TemexMatch) -> Self {
        m.range()
    }
}

impl TemexMatch {
    /// Returns the start index of the match.
    pub fn start(&self) -> usize {
        self.start
    }

    /// Returns the end index of the match.
    pub fn end(&self) -> usize {
        self.end
    }

    /// Returns the length, in trace elements, of the match.
    pub fn len(&self) -> usize {
        self.end - self.start
    }

    /// Returns true if and only if this match has a length of zero.
    pub fn is_empty(&self) -> bool {
        self.end == self.start
    }

    /// Returns the range over the start and end indices of the match.
    pub fn range(&self) -> Range<usize> {
        self.start..self.end
    }

    pub(crate) fn new(start: usize, end: usize) -> TemexMatch {
        TemexMatch { start, end }
    }
}