/rust/registry/src/index.crates.io-1949cf8c6b5b557f/rust_decimal-1.41.0/src/fuzz.rs
Line | Count | Source |
1 | | use crate::Decimal; |
2 | | |
3 | | use arbitrary::{Arbitrary, Result as ArbitraryResult, Unstructured}; |
4 | | |
5 | | impl Arbitrary<'_> for crate::Decimal { |
6 | 43.1k | fn arbitrary(u: &mut Unstructured<'_>) -> ArbitraryResult<Self> { |
7 | 43.1k | let lo = u32::arbitrary(u)?; |
8 | 43.1k | let mid = u32::arbitrary(u)?; |
9 | 43.1k | let hi = u32::arbitrary(u)?; |
10 | 43.1k | let negative = bool::arbitrary(u)?; |
11 | 43.1k | let scale = u32::arbitrary(u)? % (Self::MAX_SCALE + 1); |
12 | 43.1k | Ok(Decimal::from_parts(lo, mid, hi, negative, scale)) |
13 | 43.1k | } |
14 | | } |