pub trait SendRefCountedPointer {
type Of<'a, T: ?Sized + Send + Sync + 'a>: Clone + Send + Sync + Deref<Target = T> + 'a;
// Required method
fn new<'a, T: Send + Sync + 'a>(value: T) -> Self::Of<'a, T>
where Self::Of<'a, T>: Sized;
}Expand description
Thread-safe counterpart to
RefCountedPointer.
This is an independent trait (not a supertrait of RefCountedPointer),
matching the pattern used by SendCloneFn (independent of CloneFn).
Both traits have their own associated type with different bounds:
RefCountedPointer::Of requires Clone + Deref, while
SendRefCountedPointer::Of requires Clone + Send + Sync + Deref.
Required Associated Types§
Required Methods§
Sourcefn new<'a, T: Send + Sync + 'a>(value: T) -> Self::Of<'a, T>
fn new<'a, T: Send + Sync + 'a>(value: T) -> Self::Of<'a, T>
Wraps a sized value in a thread-safe pointer.
§Type Signature
forall T. T -> Self T
§Type Parameters
'a: The lifetime of the value.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.