Skip to main content

IntoExternalPtr

Trait IntoExternalPtr 

Source
pub trait IntoExternalPtr: TypedExternal { }
Expand description

Marker trait for types that should be converted to R as ExternalPtr.

When a type implements this trait (via #[derive(ExternalPtr)]), it gets a blanket IntoR implementation that wraps the value in ExternalPtr<T>.

This allows returning the type directly from #[miniextendr] functions:

#[derive(ExternalPtr)]
struct MyData { value: i32 }

#[miniextendr]
fn create_data(v: i32) -> MyData {
    MyData { value: v }  // Automatically wrapped in ExternalPtr
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§