Struct extendr_api::wrapper::externalptr::ExternalPtr[][src]

pub struct ExternalPtr<T> { /* fields omitted */ }
Expand description

Wrapper for creating R objects containing any Rust object.

use extendr_api::prelude::*;
test! {
    let extptr = ExternalPtr::from_val(1);
    assert_eq!(*extptr, 1);
    let robj : Robj = extptr.into();
    let extptr2 : ExternalPtr<i32> = robj.try_into().unwrap();
    assert_eq!(*extptr2, 1);
}

Implementations

Construct an external pointer object from any type T. In this case, the R object owns the data and will drop the Rust object when the last reference is removed via register_c_finalizer.

Get the “tag” of an external pointer. This is the type name in the common case.

Get the “protected” field of an external pointer. This is NULL in the common case.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This allows us to treat the Robj as if it is the type T.

The resulting type after dereferencing.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.