Skip to main content

RawRdReal

Enum RawRdReal 

Source
pub enum RawRdReal {
    Na,
    Finite(f64),
    Nan,
    PositiveInfinity,
    NegativeInfinity,
}
Expand description

A single value in an R real vector.

The special values use dedicated variants so serde formats such as JSON never collapse NA, NaN, and positive or negative infinity into the same null representation. This guarantee depends on Finite itself only ever holding an actual finite payload – see its documentation for the invariant.

§Why the invariant is documented rather than enforced

Nothing at the type level stops a caller from constructing Finite(f64::NAN) or Finite(f64::INFINITY). Leaving that unenforced is a deliberate trade-off:

  • Within this crate the only producer is the RDS lowering (lower_raw_real in rds.rs), which classifies every incoming value (NA / NaN / positive or negative infinity / finite) into the matching variant before construction, so lowering can never produce a non-finite Finite.
  • Empirically, real (double) vectors do not occur in real-world R help databases at all: Rd trees consist of character data plus string/integer/logical attributes (Rd_tag, Rd_option, srcref, Rdfile, class, dynamicFlag, macro). A full scan of an installed corpus (46 packages, 3457 topics, covering both values and attributes) found zero double vectors. This type exists for completeness of the lossless raw mirror, not because such data is expected in practice.
  • For JSON specifically, the deserialize direction is already safe: JSON numbers cannot express NaN or infinities, and {"kind":"finite","value":null} fails to deserialize as f64. The unenforced direction is serialization of a hand-constructed non-finite Finite (silently emitted as null), and round-tripping through binary serde formats that can represent non-finite floats.

Given the above, enforcement (a validated newtype payload plus a custom Deserialize) was deliberately deferred; if these raw types ever become a supported input surface for external producers, that is the intended hardening path.

Variants§

§

Na

R’s NA_real_ value.

§

Finite(f64)

A finite IEEE-754 value.

This variant must only hold a finite payload; NA, NaN, and the two infinities have their own dedicated variants (Na, Nan, PositiveInfinity, NegativeInfinity). Constructing Finite with a non-finite value violates this contract: nothing prevents it at the type level, but the derived serde Serialize impl would then encode it as JSON null (serde_json’s standard treatment of non-finite floats), silently defeating the point of keeping these variants separate. See the type-level documentation for why this invariant is documented rather than enforced.

§

Nan

A non-NA IEEE-754 not-a-number value.

§

PositiveInfinity

Positive infinity.

§

NegativeInfinity

Negative infinity.

Trait Implementations§

Source§

impl Clone for RawRdReal

Source§

fn clone(&self) -> RawRdReal

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 Copy for RawRdReal

Source§

impl Debug for RawRdReal

Source§

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

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

impl<'de> Deserialize<'de> for RawRdReal

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for RawRdReal

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for RawRdReal

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RawRdReal

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.