pub struct Numeric { /* private fields */ }
Expand description
A fixed-width integer.
This type is used to pass fixed-width integers between the application code and the SQL engine.
Implementations§
Source§impl Numeric
impl Numeric
Sourcepub fn new(val_scaled: i64, prec: usize) -> Option<Self>
pub fn new(val_scaled: i64, prec: usize) -> Option<Self>
Constructs a new fixed-width integer from a scaled value and precision.
Returns None
if precision is greater or equal to 19.
§Examples
A numeric value of 12.345
can be constructed using a scaled value of
12345
and a precision of 3
:
let num = Numeric::new(12345, 3).unwrap();
assert_eq!(num.int_part(), 12);
assert_eq!(num.fract_part(), 345);
Sourcepub fn value_scaled(&self) -> i64
pub fn value_scaled(&self) -> i64
Returns the scaled value.
Sourcepub fn fract_part(&self) -> u64
pub fn fract_part(&self) -> u64
Returns the fractional part of the numeric value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Numeric
impl RefUnwindSafe for Numeric
impl Send for Numeric
impl Sync for Numeric
impl Unpin for Numeric
impl UnwindSafe for Numeric
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more