#[allow(clippy::upper_case_acronyms)]
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)]
pub struct FPDecimal {
#[schemars(with = "String")]
pub num: U256,
pub sign: i8,
}
FPDecimal implemented Copy trait, parameter in associated functions in below are passed parameters by value. So values are copied, I think we are safe to pass parameters by reference, and copy when it is necessary.
|
pub fn _int(x: FPDecimal) -> FPDecimal { |
|
let x1 = x.num; |
|
let x1_1 = x1 / FPDecimal::ONE.num; |
|
let x_final = x1_1 * FPDecimal::ONE.num; |
|
FPDecimal { num: x_final, sign: x.sign } |
|
} |
|
pub fn _fraction(x: FPDecimal) -> FPDecimal { |
|
let x1 = x.num; |
|
FPDecimal { |
|
num: x1 - FPDecimal::_int(x).num, |
|
sign: x.sign, |
|
} |
|
} |
FPDecimalimplementedCopytrait, parameter in associated functions in below are passed parameters by value. So values are copied, I think we are safe to pass parameters by reference, and copy when it is necessary.cw-injective/packages/injective-math/src/fp_decimal/mod.rs
Lines 116 to 121 in cb5b322
cw-injective/packages/injective-math/src/fp_decimal/mod.rs
Lines 131 to 137 in cb5b322