Struct fixed_decimal::ScientificDecimal
source · pub struct ScientificDecimal { /* private fields */ }
Expand description
A struct containing a FixedDecimal
significand together with an exponent, representing a
number written in scientific notation, such as 1.729×10³.
This structure represents any 0s shown in the significand and exponent, and an optional sign for both the significand and the exponent.
Implementations§
source§impl ScientificDecimal
impl ScientificDecimal
pub fn from(significand: FixedDecimal, exponent: FixedInteger) -> Self
source§impl ScientificDecimal
impl ScientificDecimal
pub fn try_from_str(s: &str) -> Result<Self, ParseError>
pub fn try_from_utf8(code_units: &[u8]) -> Result<Self, ParseError>
Trait Implementations§
source§impl Clone for ScientificDecimal
impl Clone for ScientificDecimal
source§fn clone(&self) -> ScientificDecimal
fn clone(&self) -> ScientificDecimal
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ScientificDecimal
impl Debug for ScientificDecimal
source§impl Display for ScientificDecimal
impl Display for ScientificDecimal
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
source§impl FromStr for ScientificDecimal
impl FromStr for ScientificDecimal
source§impl PartialEq for ScientificDecimal
impl PartialEq for ScientificDecimal
source§impl Writeable for ScientificDecimal
impl Writeable for ScientificDecimal
Render the ScientificDecimal
as a string of ASCII digits with a possible decimal point,
followed by the letter ‘e’, and the exponent.
§Examples
assert_writeable_eq!(
ScientificDecimal::from(
FixedDecimal::from(1729).multiplied_pow10(-3),
FixedInteger::from(3)
),
"1.729e3"
);
assert_writeable_eq!(
ScientificDecimal::from(
FixedDecimal::from_str("+1.729").unwrap(),
FixedInteger::from_str("+03").unwrap()
),
"+1.729e+03"
);
source§fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
Writes a string to the given sink. Errors from the sink are bubbled up.
The default implementation delegates to
write_to_parts
, and discards any
Part
annotations.source§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
§fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where
S: PartsWrite + ?Sized,
fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where
S: PartsWrite + ?Sized,
Write bytes and
Part
annotations to the given sink. Errors from the
sink are bubbled up. The default implementation delegates to write_to
,
and doesn’t produce any Part
annotations.§fn write_to_string(&self) -> Cow<'_, str>
fn write_to_string(&self) -> Cow<'_, str>
Creates a new
String
with the data from this Writeable
. Like ToString
,
but smaller and faster. Read moreimpl StructuralPartialEq for ScientificDecimal
Auto Trait Implementations§
impl Freeze for ScientificDecimal
impl RefUnwindSafe for ScientificDecimal
impl Send for ScientificDecimal
impl Sync for ScientificDecimal
impl Unpin for ScientificDecimal
impl UnwindSafe for ScientificDecimal
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more