pub trait Pointer {
type Of<T: ?Sized>: Deref<Target = T>;
// Required method
fn new<T>(value: T) -> Self::Of<T>
where Self::Of<T>: Sized;
}Expand description
Base type class for heap-allocated pointers.
This is the minimal abstraction: any type that can wrap a value and dereference to it. Does NOT require Clone — that’s added by subtraits.
Required Associated Types§
Required Methods§
Sourcefn new<T>(value: T) -> Self::Of<T>
fn new<T>(value: T) -> Self::Of<T>
Wraps a sized value in the pointer.
§Type Signature
forall self t. 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 pointer type.
§Examples
use fp_library::{brands::*, classes::*};
let ptr = <RcBrand as Pointer>::new(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.