pub struct RawFactoryPointer<'a, T> { /* private fields */ }Expand description
A low-level utility used to implement custom Factory pointer types.
This is a pointer type that allows read-only access to the pointed data, except that it does
not deal with references or borrows. You cannot get a reference to the factory structure this
points to, only get a copy of the factory structure.
This allows to more easily avoid violating Rust’s strict reference rules. Instead, this type
only needs the pointer to adhere to the ptr::read function’s safety rules.
Implementations§
Source§impl<'a, T> RawFactoryPointer<'a, T>
impl<'a, T> RawFactoryPointer<'a, T>
Sourcepub fn new(inner: &'a T) -> RawFactoryPointer<'a, T>
pub fn new(inner: &'a T) -> RawFactoryPointer<'a, T>
Creates a new RawFactoryPointer from a shared reference to the factory data structure.
The lifetime of this new pointer is tied to the lifetime of the given reference.
Sourcepub const unsafe fn from_raw(raw: NonNull<T>) -> RawFactoryPointer<'a, T>
pub const unsafe fn from_raw(raw: NonNull<T>) -> RawFactoryPointer<'a, T>
Creates a new RawFactoryPointer from a non-null pointer to the factory data
structure.
§Safety
Behavior is undefined if any of the following conditions are violated for the duration of
the 'a lifetime:
rawmust be valid for reads;rawmust be properly aligned (even ifThas size0);rawmust point to a properly initialized value of typeT;- the memory
rawpoints to must not be written to, it can only be read from.
These requirements are similar to those of the ptr::read function, except this function
cannot cause UB if T is not Copy.
This is because the only method on this type that actually performs a read,
get, checks this statically via a Copy bound.
Trait Implementations§
Source§impl<'a, T> Clone for RawFactoryPointer<'a, T>where
T: Clone,
impl<'a, T> Clone for RawFactoryPointer<'a, T>where
T: Clone,
Source§fn clone(&self) -> RawFactoryPointer<'a, T>
fn clone(&self) -> RawFactoryPointer<'a, T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more