Skip to content

Commit ce78c96

Browse files
committed
refactor numeric decoding for improved readability and maintainability
1 parent 58e3fee commit ce78c96

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sqlx-core/src/mssql/types/decimal.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Decode<'_, Mssql> for Decimal {
7373

7474
fn decode_numeric(bytes: &[u8], _precision: u8, scale: u8) -> Result<Decimal, BoxDynError> {
7575
let (sign, numerator) = decode_numeric_bytes(bytes)?;
76-
76+
7777
// Try to convert to i128 to handle larger values than i64
7878
let signed_numerator = match i128::try_from(numerator) {
7979
Ok(val) => sign as i128 * val,
@@ -83,9 +83,13 @@ fn decode_numeric(bytes: &[u8], _precision: u8, scale: u8) -> Result<Decimal, Bo
8383
numerator,
8484
i128::MAX,
8585
i128::MIN
86-
).into());
86+
)
87+
.into());
8788
}
8889
};
89-
90-
Ok(Decimal::from_i128_with_scale(signed_numerator, u32::from(scale)))
90+
91+
Ok(Decimal::from_i128_with_scale(
92+
signed_numerator,
93+
u32::from(scale),
94+
))
9195
}

0 commit comments

Comments
 (0)