Repository: HigherOrderCO/Bend
File: src/fun/parser.rs (Rust)

Code before:
      Some(1)
    } else if self.try_consume_exactly("-") {
      Some(-1)
    } else {
      None
    };
    let radix = match self.peek_many(2) {
      Some("0x") => {
        self.advance_many(2);
        Radix::Hex
      }
      Some("0b") => {
        self.advance_many(2);
        Radix::Bin
      }
      _ => Radix::Dec,
    };
    let num = self.u32_with_radix(radix)?;
    let frac = if let Some('.') = self.peek_one() {
      self.advance_one();
      let ini_idx = *self.index();
      let fra_str = self.take_while(|c| c.is_digit(radix as u32) || c == '_');
      let fra_str = fra_str.chars().filter(|c| *c != '_').collect::<String>();
      let end_idx = ini_idx + fra_str.len();
      let fra = u32::from_str_radix(&fra_str, radix as u32).map_err(|e| e.to_string())?;
      let fra = fra as f32 / (radix.to_f32()).powi((end_idx - ini_idx) as i32);
      Some(fra)
    } else {
      None
    };

    if let Some(frac) = frac {
      let sign = sign.unwrap_or(1);
      return Ok(Num::F24(sign as f32 * (num as f32 + frac)));
    }

    if let Some(sign) = sign {
      let num = sign * num as i32;
      if !(-0x00800000..=0x007fffff).contains(&num) {
        return self.num_range_err(ini_idx, "I24");
      }
      Ok(Num::I24(num))
    } else {
      if num >= 1 << 24 {
        return self.num_range_err(ini_idx, "U24");
      }
      Ok(Num::U24(num))
    }
  }

  fn num_range_err<T>(&mut self, ini_idx: usize, typ: &str) -> ParseResult<T> {

Review comment (suggestion):
You could just use `fra_str.len()` directly here
```rs
      self.advance_one();
      let fra_str = self.take_while(|c| c.is_digit(radix as u32) || c == '_');
      let fra = u32::from_str_radix(&fra_str, radix as u32).map_err(|e| e.to_string())?;
      let fra = fra as f32 / (radix.to_f32()).powi(fra_str.len() as i32);
      Some(fra)
```

Code after:
      Some(1)
    } else if self.try_consume_exactly("-") {
      Some(-1)
    } else {
      None
    };
    let radix = match self.peek_many(2) {
      Some("0x") => {
        self.advance_many(2);
        Radix::Hex
      }
      Some("0b") => {
        self.advance_many(2);
        Radix::Bin
      }
      _ => Radix::Dec,
    };
    let num = self.u32_with_radix(radix)?;
    let frac = if let Some('.') = self.peek_one() {
      self.advance_one();
      let fra_str = self.take_while(|c| c.is_digit(radix as u32) || c == '_');
      let fra_str = fra_str.chars().filter(|c| *c != '_').collect::<String>();
      let fra = u32::from_str_radix(&fra_str, radix as u32).map_err(|e| e.to_string())?;
      let fra = fra as f32 / (radix.to_f32()).powi(fra_str.len() as i32);
      Some(fra)
    } else {
      None
    };

    if let Some(frac) = frac {
      let sign = sign.unwrap_or(1);
      return Ok(Num::F24(sign as f32 * (num as f32 + frac)));
    }

    if let Some(sign) = sign {
      let num = sign * num as i32;
      if !(-0x00800000..=0x007fffff).contains(&num) {
        return self.num_range_err(ini_idx, "I24");
      }
      Ok(Num::I24(num))
    } else {
      if num >= 1 << 24 {
        return self.num_range_err(ini_idx, "U24");
      }
      Ok(Num::U24(num))
    }
  }

  fn num_range_err<T>(&mut self, ini_idx: usize, typ: &str) -> ParseResult<T> {
    let msg = format!("\x1b[1mNumber literal outside of range for {}.\x1b[0m", typ);
    let end_idx = *self.index();