Debian Codegraph @

src/types/bigdecimal.rs

raw symbols SCIP
1 use bigdecimalrust-analyzer cargo bigdecimal 0.4.10 crate/::BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal#;
2 use num_bigintrust-analyzer cargo num-bigint 0.4.8 crate/::{BigIntrust-analyzer cargo num-bigint 0.4.8 bigint/BigInt#, Signrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#};
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/;
4
5 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::decoderust-analyzer cargo sqlx-core 0.8.3 decode/::Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#;
6 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::encoderust-analyzer cargo sqlx-core 0.8.3 encode/::{Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#, IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#};
7 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#;
8 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::numericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/::{PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#, PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#};
9 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#;
10 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#, PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType#, PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#, PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#};
11
12 impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# {
13 fn type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`Type<Postgres>`]type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
14 PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::NUMERICrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]NUMERIC.
15 }
16 }
17
18 impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# {
19 fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
20 PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::NUMERIC_ARRAYrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]NUMERIC_ARRAY.
21 }
22 }
23
24 impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#> for BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# {
25 type Errorrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<PgNumeric>`]Error# = BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#;
26
27 fn try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<PgNumeric>`]try_from().(numeric: PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<PgNumeric>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
28 Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<PgNumeric>`]::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<&PgNumeric>`]try_from().(&numeric)
29 }
30 }
31
32 impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<&'_ PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#> for BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# {
33 type Errorrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<&PgNumeric>`]Error# = BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#;
34
35 fn try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<&PgNumeric>`]try_from().(numeric: &'_ PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<&PgNumeric>`], Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`TryFrom<&PgNumeric>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> {
36 let (digits, sign, weight) = match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().numeric {
37 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
38 ref digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.,
39 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.,
40 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.,
41 ..
42 } => (digits, sign, weight),
43
44 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::NotANumberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#NotANumber# => {
45 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("BigDecimal does not support NaN values".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
46 }
47 };
48
49 if digits.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
50 // Postgres returns an empty digit array for 0 but BigInt expects at least one zero
51 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0u64.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
52 }
53
54 let sign = match sign {
55 PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive# => Signrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#::Plusrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#Plus#,
56 PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Negativerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Negative# => Signrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#::Minusrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#Minus#,
57 };
58
59 // weight is 0 if the decimal point falls after the first base-10000 digit
60 //
61 // `Vec` capacity cannot exceed `isize::MAX` bytes, so this cast can't wrap in practice.
62 #[allow(clippy::cast_possible_wrap)]
63 let scale = (digits.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as i64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().weight as i64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().4;
64
65 // no optimized algorithm for base-10 so use base-100 for faster processing
66 let mut cents = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(digits.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2);
67
68 #[allow(
69 clippy::cast_possible_truncation,
70 clippy::cast_possible_wrap,
71 clippy::cast_sign_loss
72 )]
73 for (i, &digit) in digits.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
74 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::is_valid_digitrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/impl#[PgNumeric]is_valid_digit().(digit) {
75 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
76 "PgNumeric to BigDecimal: {i}th digit is out of range {digit}"
77 )
78 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
79 }
80
81 cents.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((digit rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().100) as u8);
82 cents.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((digit rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().100) as u8);
83 }
84
85 let bigint = BigIntrust-analyzer cargo num-bigint 0.4.8 bigint/BigInt#::from_radix_berust-analyzer cargo num-bigint 0.4.8 bigint/impl#[BigInt]from_radix_be().(sign, &cents, 100)
86 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().("PgNumeric contained an out-of-range digit")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
87
88 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal#::newrust-analyzer cargo bigdecimal 0.4.10 impl#[BigDecimal]new().(bigint, scale))
89 }
90 }
91
92 impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<&'_ BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal#> for PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric# {
93 type Errorrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]Error# = BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#;
94
95 fn try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(decimal: &BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
96 let base_10_to_10000 = |chunk: &[u8]| chunk.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]fold().(0i16, |a, &d| a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().d as i16);
97
98 // NOTE: this unfortunately copies the BigInt internally
99 let (integer, exp) = decimal.as_bigint_and_exponentrust-analyzer cargo bigdecimal 0.4.10 impl#[BigDecimal]as_bigint_and_exponent().();
100
101 // this routine is specifically optimized for base-10
102 // FIXME: is there a way to iterate over the digits to avoid the Vec allocation
103 let (sign, base_10) = integer.to_radix_berust-analyzer cargo num-bigint 0.4.8 bigint/impl#[BigInt]to_radix_be().(10);
104
105 let base_10_len = i64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[i64][`TryFrom<usize>`]try_from().(base_10.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| {
106 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
107 "BigDecimal base-10 length out of range for PgNumeric: {}",
108 base_10.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()
109 )
110 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
111
112 // weight is positive power of 10000
113 // exp is the negative power of 10
114 let weight_10 = base_10_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().exp;
115
116 // scale is only nonzero when we have fractional digits
117 // since `exp` is the _negative_ decimal exponent, it tells us
118 // exactly what our scale should be
119 let scale: i16 = cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(0, exp).try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
120
121 // there's an implicit +1 offset in the interpretation
122 let weight: i16 = if weight_10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]le().0 {
123 weight_10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().1
124 } else {
125 // the `-1` is a fix for an off by 1 error (4 digits should still be 0 weight)
126 (weight_10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().4
127 }
128 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
129
130 let digits_len = if base_10.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 {
131 base_10.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1
132 } else {
133 base_10.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().4
134 };
135
136 // For efficiency, we want to process the base-10 digits in chunks of 4,
137 // but that means we need to deal with the non-divisible remainder first.
138 let offset = weight_10.rem_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]rem_euclid().(4);
139
140 // Do a checked conversion to the smallest integer,
141 // so we can widen arbitrarily without triggering lints.
142 let offset = u8::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u8][`TryFrom<i64>`]try_from().(offset).unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|_| {
143 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("BUG: `offset` should be in the range [0, 4) but is {offset}")
144 });
145
146 let mut digits = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(digits_len);
147
148 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first) = base_10.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#offset as usize) {
149 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().first.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
150 digits.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(base_10_to_10000(first));
151 }
152 } else if offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 {
153 // If we didn't hit the `if let Some` branch,
154 // then `base_10.len()` must strictly be smaller
155 #[allow(clippy::cast_possible_truncation)]
156 let power = (offset as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().base_10.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()) as u32;
157
158 digits.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(base_10_to_10000(&base_10) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().10i16.powrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]pow().(power));
159 }
160
161 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest) = base_10.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(offset as usize..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#) {
162 // `chunk.len()` is always between 1 and 4
163 #[allow(clippy::cast_possible_truncation)]
164 digits.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(
165 rest.chunksrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks().(4)
166 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|chunk| base_10_to_10000(chunk) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().10i16.powrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]pow().(4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().chunk.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u32)),
167 );
168 }
169
170 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&0) = digits.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().() {
171 digits.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().();
172 }
173
174 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
175 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: sign_to_pgrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/sign_to_pg().(sign),
176 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.,
177 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.,
178 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.,
179 })
180 }
181 }
182
183 #[doc=include_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_str!!("bigdecimal-range.md")]
184 impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# {
185 fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`Encode<'_, Postgres>`]encode_by_ref().(&self, buf: &mut PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
186 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(self)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..encoderust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/impl#[PgNumeric]encode().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
187
188 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#::Norust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#No#)
189 }
190
191 fn size_hintrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`Encode<'_, Postgres>`]size_hint().(&self) -> usize {
192 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::size_hintrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/impl#[PgNumeric]size_hint().(self.digitsrust-analyzer cargo bigdecimal 0.4.10 impl#[BigDecimal]digits().())
193 }
194 }
195
196 /// ### Note: `NaN`
197 /// `BigDecimal` has a greater range than `NUMERIC` (see the corresponding `Encode` impl for details)
198 /// but cannot represent `NaN`, so decoding may return an error.
199 impl Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# {
200 fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`Decode<'_, Postgres>`]decode().(value: PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[BigDecimal][`Decode<'_, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
201 match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() {
202 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::decoderust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/impl#[PgNumeric]decode().(value.as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().(),
203 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value.as_strrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_str().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
204 }
205 }
206 }
207
208 fn sign_to_pgrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/sign_to_pg().(sign: Signrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#) -> PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign# {
209 match sign {
210 Signrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#::Plusrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#Plus# | Signrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#::NoSignrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#NoSign# => PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
211 Signrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#::Minusrust-analyzer cargo num-bigint 0.4.8 bigint/Sign#Minus# => PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Negativerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Negative#,
212 }
213 }
214
215 #[cfg(test)]
216 mod bigdecimal_to_pgnumericrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/ {
217 use superrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/::{BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal#, PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#, PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#};
218 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#;
219
220 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
221 fn zerorust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/zero().() {
222 let zero: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "0".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
223
224 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
225 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&zero).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
226 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
227 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
228 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
229 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 0,
230 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]
231 }
232 );
233 }
234
235 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
236 fn onerust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/one().() {
237 let one: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "1".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
238 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
239 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&one).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
240 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
241 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
242 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
243 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 0,
244 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1]
245 }
246 );
247 }
248
249 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
250 fn tenrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/ten().() {
251 let ten: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "10".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
252 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
253 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&ten).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
254 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
255 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
256 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
257 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 0,
258 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![10]
259 }
260 );
261 }
262
263 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
264 fn one_hundredrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/one_hundred().() {
265 let one_hundred: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "100".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
266 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
267 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&one_hundred).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
268 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
269 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
270 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
271 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 0,
272 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![100]
273 }
274 );
275 }
276
277 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
278 fn ten_thousandrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/ten_thousand().() {
279 // BigDecimal doesn't normalize here
280 let ten_thousand: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "10000".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
281 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
282 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&ten_thousand).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
283 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
284 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
285 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
286 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 1,
287 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1]
288 }
289 );
290 }
291
292 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
293 fn two_digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/two_digits().() {
294 let two_digits: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "12345".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
295 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
296 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&two_digits).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
297 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
298 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
299 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
300 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 1,
301 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2345]
302 }
303 );
304 }
305
306 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
307 fn one_tenthrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/one_tenth().() {
308 let one_tenth: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "0.1".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
309 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
310 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&one_tenth).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
311 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
312 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
313 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 1,
314 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1,
315 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1000]
316 }
317 );
318 }
319
320 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
321 fn one_hundredthrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/one_hundredth().() {
322 let one_hundredth: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "0.01".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
323 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
324 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&one_hundredth).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
325 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
326 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
327 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 2,
328 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1,
329 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![100]
330 }
331 );
332 }
333
334 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
335 fn twelve_thousandthsrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/twelve_thousandths().() {
336 let twelve_thousandths: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "0.012".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
337 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
338 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&twelve_thousandths).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
339 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
340 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
341 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 3,
342 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1,
343 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![120]
344 }
345 );
346 }
347
348 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
349 fn decimal_1rust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/decimal_1().() {
350 let decimal: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "1.2345".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
351 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
352 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&decimal).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
353 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
354 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
355 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 4,
356 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 0,
357 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2345]
358 }
359 );
360 }
361
362 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
363 fn decimal_2rust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/decimal_2().() {
364 let decimal: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "0.12345".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
365 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
366 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&decimal).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
367 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
368 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
369 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 5,
370 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1,
371 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1234, 5000]
372 }
373 );
374 }
375
376 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
377 fn decimal_3rust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/decimal_3().() {
378 let decimal: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "0.01234".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
379 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
380 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&decimal).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
381 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
382 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
383 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 5,
384 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1,
385 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0123, 4000]
386 }
387 );
388 }
389
390 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
391 fn decimal_4rust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/decimal_4().() {
392 let decimal: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "12345.67890".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
393 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
394 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&decimal).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
395 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
396 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
397 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 5,
398 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 1,
399 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2345, 6789]
400 }
401 );
402 }
403
404 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
405 fn one_digit_decimalrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/one_digit_decimal().() {
406 let one_digit_decimal: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "0.00001234".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
407 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
408 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&one_digit_decimal).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
409 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
410 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
411 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 8,
412 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2,
413 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1234]
414 }
415 );
416 }
417
418 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
419 fn issue_423_four_digitrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/issue_423_four_digit().() {
420 // This is a regression test for https://github.com/launchbadge/sqlx/issues/423
421 let four_digit: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "1234".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
422 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
423 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&four_digit).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
424 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
425 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
426 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
427 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 0,
428 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1234]
429 }
430 );
431 }
432
433 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
434 fn issue_423_negative_four_digitrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/issue_423_negative_four_digit().() {
435 // This is a regression test for https://github.com/launchbadge/sqlx/issues/423
436 let negative_four_digit: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "-1234".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
437 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
438 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&negative_four_digit).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
439 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
440 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Negativerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Negative#,
441 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
442 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 0,
443 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1234]
444 }
445 );
446 }
447
448 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
449 fn issue_423_eight_digitrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/issue_423_eight_digit().() {
450 // This is a regression test for https://github.com/launchbadge/sqlx/issues/423
451 let eight_digit: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "12345678".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
452 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
453 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&eight_digit).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
454 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
455 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Positiverust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Positive#,
456 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
457 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 1,
458 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1234, 5678]
459 }
460 );
461 }
462
463 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
464 fn issue_423_negative_eight_digitrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/bigdecimal_to_pgnumeric/issue_423_negative_eight_digit().() {
465 // This is a regression test for https://github.com/launchbadge/sqlx/issues/423
466 let negative_eight_digit: BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal# = "-12345678".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
467 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
468 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::try_fromrust-analyzer cargo sqlx-postgres 0.8.3 types/bigdecimal/impl#[PgNumeric][`TryFrom<&BigDecimal>`]try_from().(&negative_eight_digit).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
469 PgNumericrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#::Numberrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number# {
470 signrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#sign.: PgNumericSignrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#::Negativerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumericSign#Negative#,
471 scalerust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#scale.: 0,
472 weightrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#weight.: 1,
473 digitsrust-analyzer cargo sqlx-postgres 0.8.3 types/numeric/PgNumeric#Number#digits.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1234, 5678]
474 }
475 );
476 }
477 }