Skip to main content

Real

Struct Real 

Source
pub struct Real(/* private fields */);
Expand description

A CIM Float or Decimal value: the number, and the spelling it arrived in.

Like Mrid, two Reals denoting one number are equal whatever they were written as, so a difference never reports a reformatting, while re-export reproduces the spelling (2.62637E-05, 250.000000, -90E6).

A spelling is kept only when it is a conforming lexical form for the primitive it was read as; tolerated deviations such as 1,5 or 1.5D+3 (Value::parse_primitive) are written back in canonical form.

Implementations§

Source§

impl Real

Source

pub fn new(value: f64) -> Real

A number with no particular spelling: it renders canonically.

Source

pub fn from_document(value: f64, text: &str, prim: Primitive) -> Real

A number as a document wrote it.

The text is kept only when it differs from what this crate would write anyway and is a conforming lexical form for prim — so a value that was already canonical costs nothing, and a deviating one is repaired rather than echoed.

Source

pub fn get(&self) -> f64

Source

pub fn lexical(&self) -> Option<&str>

The spelling this value was read with, where it differs from the canonical form.

Source

pub fn to_lexical_as(&self, prim: Primitive) -> String

How to write it: the document’s spelling where there is one, else canonical.

Trait Implementations§

Source§

impl Clone for Real

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Real

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Real

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Real> for Value

Source§

fn from(r: Real) -> Value

Converts to this type from the input type.
Source§

impl From<f64> for Real

Source§

fn from(value: f64) -> Real

Converts to this type from the input type.
Source§

impl PartialEq for Real

Equality is the number, not the spelling: 1.0 read from a file equals 1 computed in memory. It is f64 equality, so NaN equals nothing, itself included.

Source§

fn eq(&self, other: &Real) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for Real

§

impl Freeze for Real

§

impl Move for Real

§

impl RefUnwindSafe for Real

§

impl Send for Real

§

impl Sync for Real

§

impl Unpin for Real

§

impl UnsafeUnpin for Real

§

impl UnwindSafe for Real

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.