Skip to main content

RClone

Trait RClone 

Source
pub trait RClone {
    // Required method
    fn clone(&self) -> Self;
}
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

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

§Example

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

#[miniextendr]
impl RClone for Buffer {}

In R:

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

Required Methods§

Source

fn clone(&self) -> Self

Create a deep copy of this value.

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