Skip to main content

SendRefCountedPointer

Trait SendRefCountedPointer 

Source
pub trait SendRefCountedPointer: RefCountedPointer {
    type SendOf<T: ?Sized + Send + Sync>: Clone + Send + Sync + Deref<Target = T>;

    // Required method
    fn send_new<T: Send + Sync>(value: T) -> Self::SendOf<T>
       where Self::SendOf<T>: Sized;
}
Expand description

Extension trait for thread-safe reference-counted pointers.

This follows the same pattern as SendCloneableFn extends CloneableFn, adding a SendOf associated type with explicit Send + Sync bounds.

Required Associated Types§

Source

type SendOf<T: ?Sized + Send + Sync>: Clone + Send + Sync + Deref<Target = T>

The thread-safe pointer type constructor.

For ArcBrand, this is Arc<T> where T: Send + Sync.

Required Methods§

Source

fn send_new<T: Send + Sync>(value: T) -> Self::SendOf<T>
where Self::SendOf<T>: Sized,

Wraps a sized value in a thread-safe pointer.

§Type Signature

forall self t. Send self => t -> self t

§Type Parameters
  • T: The type of the value to wrap.
§Parameters
  • value: The value to wrap.
§Returns

The value wrapped in the thread-safe pointer type.

§Examples
use fp_library::{brands::*, functions::*};

let ptr = send_ref_counted_pointer_new::<ArcBrand, _>(42);
assert_eq!(*ptr, 42);

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§