pub unsafe trait SharedPtrTarget { }
Expand description

Trait bound for types which may be used as the T inside of a SharedPtr<T> in generic code.

This trait has no publicly callable or implementable methods. Implementing it outside of the CXX codebase is not supported.

Example

A bound T: SharedPtrTarget may be necessary when manipulating SharedPtr in generic code.

use cxx::memory::{SharedPtr, SharedPtrTarget};
use std::fmt::Display;

pub fn take_generic_ptr<T>(ptr: SharedPtr<T>)
where
    T: SharedPtrTarget + Display,
{
    println!("the shared_ptr points to: {}", *ptr);
}

Writing the same generic function without a SharedPtrTarget trait bound would not compile.

Implementations on Foreign Types§

source§

impl SharedPtrTarget for isize

source§

impl SharedPtrTarget for i16

source§

impl SharedPtrTarget for u64

source§

impl SharedPtrTarget for f32

source§

impl SharedPtrTarget for f64

source§

impl SharedPtrTarget for u32

source§

impl SharedPtrTarget for u16

source§

impl SharedPtrTarget for u8

source§

impl SharedPtrTarget for i64

source§

impl SharedPtrTarget for i32

source§

impl SharedPtrTarget for bool

source§

impl SharedPtrTarget for usize

source§

impl SharedPtrTarget for i8

Implementors§