Skip to content

Commit

Permalink
chore: manually fix clippy::cast_possible_truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulmathur16 authored and JayWhite2357 committed Oct 3, 2024
1 parent 67102cf commit 743a3cf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/proof-of-sql-parser/src/intermediate_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,19 @@ impl IntermediateDecimal {
/// Get the precision of the fixed-point representation of this intermediate decimal.
#[must_use]
pub fn precision(&self) -> u8 {
self.value.digits() as u8
match u8::try_from(self.value.digits()) {
Ok(v) => v,
Err(_) => u8::MAX, // Returning u8::MAX on truncation
}
}

/// Get the scale of the fixed-point representation of this intermediate decimal.
#[must_use]
pub fn scale(&self) -> i8 {
self.value.fractional_digit_count() as i8
match i8::try_from(self.value.fractional_digit_count()) {
Ok(v) => v,
Err(_) => i8::MAX, // Returning i8::MAX on truncation
}
}

/// Attempts to convert the decimal to `BigInt` while adjusting it to the specified precision and scale.
Expand Down

0 comments on commit 743a3cf

Please sign in to comment.