Skip to main content

RPartialOrd

Trait RPartialOrd 

Source
pub trait RPartialOrd {
    // Required method
    fn partial_cmp(&self, other: &Self) -> Option<i32>;
}
Expand description

Adapter trait for std::cmp::PartialOrd.

Provides partial ordering comparison for R, handling incomparable values. Automatically implemented for any type that implements PartialOrd.

§Methods

  • partial_cmp(&self, other: &Self) - Returns Some(-1/0/1) or None

§Example

// f64 has partial ordering (NaN is not comparable)
#[derive(PartialOrd, PartialEq, ExternalPtr)]
struct MyFloat(f64);

#[miniextendr]
impl RPartialOrd for MyFloat {}

Required Methods§

Source

fn partial_cmp(&self, other: &Self) -> Option<i32>

Compare with another value, returning None if incomparable.

Returns:

  • Some(-1) if self < other
  • Some(0) if self == other
  • Some(1) if self > other
  • None if values are incomparable (maps to NA in R)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§