pub struct OpaquePtr<T>(/* private fields */);
Expand description
This structure can be used to store a statically bound reference &'static T
in a
safe wrapper that also implements Send
and Sync
. These traits are implemented
because the content cannot be recovered after the construction, and also because
the pointer has a static lifetime.
This opaque pointer also implements Hash
and Eq
to be usable as a map key.
Implementations§
Source§impl<T> OpaquePtr<T>
impl<T> OpaquePtr<T>
pub const fn new(rf: &'static T) -> Self
pub fn inner(self) -> &'static T
Trait Implementations§
impl<T: Copy> Copy for OpaquePtr<T>
impl<T> Eq for OpaquePtr<T>
impl<T> Send for OpaquePtr<T>
impl<T> Sync for OpaquePtr<T>
Auto Trait Implementations§
impl<T> Freeze for OpaquePtr<T>
impl<T> RefUnwindSafe for OpaquePtr<T>where
T: RefUnwindSafe,
impl<T> Unpin for OpaquePtr<T>
impl<T> UnwindSafe for OpaquePtr<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more