Skip to main content

RDisplay

Trait RDisplay 

Source
pub trait RDisplay {
    // Required method
    fn as_r_string(&self) -> String;

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

Adapter trait for std::fmt::Display.

Provides user-friendly string conversion for R. Automatically implemented for any type that implements Display.

§Methods

  • as_r_string() - Returns the Display representation

§Example

ⓘ
struct Version(u32, u32, u32);

impl Display for Version {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}.{}.{}", self.0, self.1, self.2)
    }
}

#[miniextendr]
impl miniextendr_api::adapter_traits::RDisplay for Version {}

Required Methods§

Source

fn as_r_string(&self) -> String

Convert to a user-friendly string.

Provided Methods§

Source

#[doc(hidden)]
unsafe extern "C" fn __RDisplay_as_r_string_shim( data: *mut c_void, argc: i32, argv: *const SEXP, ) -> SEXP
where Self: Sized + RDisplay,

Method shim for RDisplay::as_r_string.

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 dyn compatible.

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

Implementors§

Source§

impl<T: Display> RDisplay for T