pub struct PgNumeric(/* private fields */);Expand description
A PostgreSQL numeric, equal, ordered and hashed by value as cmp_numerics compares it, with
NaN equal to itself and above Infinity.
Its Display is numeric_out, so equal values can print differently.
use sql_values::{CastTarget, CastValue, Literal, cast_literal};
let numeric = |text| match cast_literal(Literal::Quoted(text), CastTarget::Numeric(None)) {
Ok(CastValue::Numeric(value)) => value,
other => panic!("{other:?}"),
};
assert_eq!(numeric("1.50"), numeric("1.5"));
assert_eq!(numeric("1.50").to_string(), "1.50");
assert!(numeric("NaN") > numeric("Infinity"));
assert!(numeric("-inf") < numeric("-1e1000"));Trait Implementations§
impl Eq for PgNumeric
Source§impl Ord for PgNumeric
cmp_numerics, ordering -Infinity below finite values by value, then Infinity, then NaN.
impl Ord for PgNumeric
cmp_numerics, ordering -Infinity below finite values by value, then Infinity, then NaN.
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Auto Trait Implementations§
impl Forget for PgNumeric
impl Freeze for PgNumeric
impl RefUnwindSafe for PgNumeric
impl Send for PgNumeric
impl Sync for PgNumeric
impl Unpin for PgNumeric
impl UnsafeUnpin for PgNumeric
impl UnwindSafe for PgNumeric
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