Skip to content

Commit

Permalink
Refactored MIN/MAX range code from lt/gt to !RangeInclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
1Git2Clone committed Nov 17, 2024
1 parent 83214ed commit 3f257c3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/hw1/task_1.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::utils::{input::get_numeric_input, Error};

const MIN_NUM_SYSTEM: u8 = 2;
const MAX_NUM_SYSTEM: u8 = 16;
const MIN: u8 = 1;
const MAX: u8 = 100;
const MIN_NUM_SYSTEM: u32 = 2;
const MAX_NUM_SYSTEM: u32 = 16;
const MIN: u32 = 1;
const MAX: u32 = 100;

/// # HOMEWORK 1 | TASK 1
///
Expand Down Expand Up @@ -35,8 +35,8 @@ pub struct Solution;

impl Solution {
pub fn main(numeric_system: u32, mut decimal_input: u32) -> String {
if (numeric_system < MIN_NUM_SYSTEM.into() || numeric_system > MAX_NUM_SYSTEM.into())
|| (decimal_input < MIN.into() || decimal_input > MAX.into())
if (!(MIN_NUM_SYSTEM..=MAX_NUM_SYSTEM).contains(&numeric_system))
|| (!(MIN..=MAX).contains(&decimal_input))
{
return String::from("Invalid input data!");
}
Expand Down

0 comments on commit 3f257c3

Please sign in to comment.