seqgen/sequence_part/
states.rs

1//! This module defines states that the SequencePart could be one of
2
3/// A type that represents the state of SequencePart
4/// when its used to represents the alive elements of the sequence.
5#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
6pub struct AliveElements;
7
8// A type that represents the state of SequencePart
9/// when its used to represents a range of the sequence.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
11pub struct Range {
12    start: usize,
13    end: usize,
14}
15
16impl Range {
17    /// Create new instance.
18    pub(super) fn new(start: usize, end: usize) -> Self {
19        Self { start, end }
20    }
21
22    /// Returns the start of the range.
23    pub(super) fn start(&self) -> usize {
24        self.start
25    }
26
27    /// Returns the end of the range.
28    pub(super) fn end(&self) -> usize {
29        self.end
30    }
31
32    /// Checks if an element is in range.
33    pub fn nth_element_is_in_range(&self, index: usize) -> bool {
34        index >= self.start() && index < self.end()
35    }
36}