Struct bson::decimal128::Decimal128 [−][src]
pub struct Decimal128 { /* fields omitted */ }
Expand description
Decimal128 type.
Currently, this type does not have any functionality and can only be serialized and deserialized from existing documents that contain BSON decimal128s.
Experimental functionality can be enabled through the usage of the "decimal128"
feature flag. The flag is not recommended for use however, as it causes Decimal128
values to
serialize to BSON incorrectly. See this issue for
more information.
Note that the API and behavior of the feature-gated functionality are unstable and subject to change, and the feature flag will be removed completely in 2.0.0.
Implementations
👎 Deprecated: The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
Construct a Decimal128
from string.
For example:
NaN
Infinity
orInf
1.0
,+37.0
,0.73e-7
,.5
use bson::decimal128::Decimal128;
let dec128 = Decimal128::from_str("1.05E+3");
👎 Deprecated: The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
Construct a Decimal128
from a i32
number.
use bson::decimal128::Decimal128;
let num: i32 = 23;
let dec128 = Decimal128::from_i32(num);
👎 Deprecated: The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
Construct a Decimal128
from a u32
number.
use bson::decimal128::Decimal128;
let num: u32 = 78;
let dec128 = Decimal128::from_u32(num);
👎 Deprecated since 0.15.0: Replaced by to_i32
Replaced by to_i32
Construct a Decimal128
from a i32
number.
use bson::decimal128::Decimal128;
let num: i32 = 23;
let dec128 = Decimal128::from_i32(num);
let int = dec128.into_i32();
assert_eq!(int, num);
👎 Deprecated: The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
Construct a Decimal128
from a i32
number.
use bson::decimal128::Decimal128;
let num: i32 = 23;
let dec128 = Decimal128::from_i32(num);
let int = dec128.to_i32();
assert_eq!(int, num);
👎 Deprecated since 0.15.0: Replaced by to_u32
Replaced by to_u32
Construct a Decimal128
from a i32
number.
use bson::decimal128::Decimal128;
let num: u32 = 23;
let dec128 = Decimal128::from_u32(num);
let int = dec128.into_u32();
assert_eq!(int, num);
👎 Deprecated: The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
Construct a Decimal128
from a i32
number.
use bson::decimal128::Decimal128;
let num: u32 = 23;
let dec128 = Decimal128::from_u32(num);
let int = dec128.to_u32();
assert_eq!(int, num);
👎 Deprecated: The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
Create a new Decimal128 as 0
.
use bson::decimal128::Decimal128;
let dec128 = Decimal128::zero();
👎 Deprecated: The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
Check if value is NaN
use bson::decimal128::Decimal128;
let num: u32 = 78;
let dec128 = Decimal128::from_u32(num);
assert!(!dec128.is_nan());
👎 Deprecated: The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
The feature-gated decimal128 implementation serializes to BSON incorrectly and should not be used. It will be removed completely in 2.0.0
Check if value is 0
use bson::decimal128::Decimal128;
let num: u32 = 0;
let dec128 = Decimal128::from_u32(num);
assert!(dec128.is_zero());
Trait Implementations
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Decimal128
impl Send for Decimal128
impl Sync for Decimal128
impl Unpin for Decimal128
impl UnwindSafe for Decimal128
Blanket Implementations
Mutably borrows from an owned value. Read more