Skip to main content

Module typed_external_macro

Module typed_external_macro 

Source
Expand description

impl_typed_external! — explicit monomorphization of TypedExternal for generic types.

Since #[derive(ExternalPtr)] rejects generic types (the generated .Call entrypoints and R wrapper code cannot be generic), this macro provides an alternative for users who want to use ExternalPtr<T> with a specific monomorphization of a generic type.

§Usage

impl_typed_external!(MyWrapper<i32>);
impl_typed_external!(MyWrapper<String>);
impl_typed_external!(TreeNode<String, Vec<u8>>);

§Generated Code

For impl_typed_external!(MyWrapper<i32>):

impl TypedExternal for MyWrapper<i32> {
    const TYPE_NAME: &'static str = "MyWrapper<i32>";
    const TYPE_NAME_CSTR: &'static [u8] = b"MyWrapper<i32>\0";
    const TYPE_ID_CSTR: &'static [u8] =
        concat!(env!("CARGO_PKG_NAME"), "@", env!("CARGO_PKG_VERSION"),
                "::", module_path!(), "::MyWrapper<i32>\0").as_bytes();
}

impl IntoExternalPtr for MyWrapper<i32> {}

Functions§

impl_typed_external
Implementation of impl_typed_external!.