Skip to main content

ROrd

Trait ROrd 

Source
pub trait ROrd {
    // Required method
    fn r_cmp(&self, other: &Self) -> i32;

    // Provided method
#[doc(hidden)]
unsafe extern "C" fn __ROrd_r_cmp_shim( data: *mut c_void, argc: i32, argv: *const SEXP, ) -> SEXP where Self: Sized + ROrd + TypedExternal + Send + 'static { ... } }
Expand description

Adapter trait for std::cmp::Ord.

Provides total ordering comparison for R sorting operations. Automatically implemented for any type that implements Ord.

§Methods

  • r_cmp(&self, other: &Self) (cmp() in R) - Returns -1, 0, or 1

§Example

ⓘ
#[derive(Ord, PartialOrd, Eq, PartialEq, ExternalPtr)]
struct Priority(u32);

#[miniextendr]
impl miniextendr_api::adapter_traits::ROrd for Priority {}

Required Methods§

Source

fn r_cmp(&self, other: &Self) -> i32

Compare with another value.

Returns:

  • -1 if self < other
  • 0 if self == other
  • 1 if self > other

Provided Methods§

Source

#[doc(hidden)]
unsafe extern "C" fn __ROrd_r_cmp_shim( data: *mut c_void, argc: i32, argv: *const SEXP, ) -> SEXP
where Self: Sized + ROrd + TypedExternal + Send + 'static,

Method shim for ROrd::r_cmp.

Converts SEXP arguments, calls the method, and returns SEXP result. Both Rust panics and R longjmps are caught via with_r_unwind_protect.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Ord> ROrd for T