Skip to content

Commit

Permalink
refactor: added i8 type for RangeBoundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
m62624 committed Aug 28, 2023
1 parent 519e909 commit 5b029cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions flexible_inspect_rs/src/rules/common_elements/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ pub enum RangeFormat {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub enum RangeBoundaries {
I8(RangeInclusive<i8>),
I32(RangeInclusive<i32>),
I64(RangeInclusive<i64>),
I128(RangeInclusive<i128>),
F32(RangeInclusive<f32>),
F64(RangeInclusive<f64>),
}

impl RangeType for RangeInclusive<i8> {
fn get_range(self) -> RangeBoundaries {
RangeBoundaries::I8(self)
}
}

impl RangeType for RangeInclusive<i32> {
fn get_range(self) -> RangeBoundaries {
RangeBoundaries::I32(self)
Expand Down Expand Up @@ -65,6 +72,7 @@ pub enum RangeMode {
impl Hash for RangeBoundaries {
fn hash<H: Hasher>(&self, state: &mut H) {
match self {
RangeBoundaries::I8(range) => range.hash(state),
RangeBoundaries::I32(range) => range.hash(state),
RangeBoundaries::I64(range) => range.hash(state),
RangeBoundaries::I128(range) => range.hash(state),
Expand All @@ -83,6 +91,7 @@ impl Hash for RangeBoundaries {
impl PartialEq for RangeBoundaries {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(RangeBoundaries::I8(range1), RangeBoundaries::I8(range2)) => range1 == range2,
(RangeBoundaries::I32(range1), RangeBoundaries::I32(range2)) => range1 == range2,
(RangeBoundaries::I64(range1), RangeBoundaries::I64(range2)) => range1 == range2,
(RangeBoundaries::I128(range1), RangeBoundaries::I128(range2)) => range1 == range2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ where
None
}
}


0 comments on commit 5b029cf

Please sign in to comment.