Skip to main content

RClone

Trait RClone 

Source
pub trait RClone {
    // Required method
    fn r_clone(&self) -> Self;

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

Adapter trait for std::clone::Clone.

Provides explicit deep copying for R. This is useful when R users need to create independent copies of Rust objects (which normally use reference semantics via ExternalPtr).

§Methods

  • r_clone() (clone() in R) - Create a deep copy of this value

§Example

ⓘ
#[derive(Clone, ExternalPtr)]
struct Buffer { data: Vec<u8> }

#[miniextendr]
impl miniextendr_api::adapter_traits::RClone for Buffer {}

In R:

buf1 <- Buffer$new(...)
buf2 <- buf1$RClone$clone()  # Independent copy

Required Methods§

Source

fn r_clone(&self) -> Self

Create a deep copy of this value.

Provided Methods§

Source

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

Method shim for RClone::r_clone.

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: Clone> RClone for T