pub struct Unique<T: ?Sized> {
pointer: NonNull<T>,
_marker: PhantomData<T>,
}
kernel_ptr
)Fieldsยง
ยงpointer: NonNull<T>
kernel_ptr
)_marker: PhantomData<T>
kernel_ptr
)Implementationsยง
Sourceยงimpl<T: ?Sized> Unique<T>
impl<T: ?Sized> Unique<T>
Sourcepub const unsafe fn new(ptr: *mut T) -> Unique<T>
๐ฌThis is a nightly-only experimental API. (kernel_ptr
)
pub const unsafe fn new(ptr: *mut T) -> Unique<T>
kernel_ptr
)Sourcepub fn as_ptr(self) -> *mut T
๐ฌThis is a nightly-only experimental API. (kernel_ptr
)
pub fn as_ptr(self) -> *mut T
kernel_ptr
)Acquires the underlying *mut
pointer.
Sourcepub unsafe fn as_ref(&self) -> &T
๐ฌThis is a nightly-only experimental API. (kernel_ptr
)
pub unsafe fn as_ref(&self) -> &T
kernel_ptr
)Dereferences the content.
The resulting lifetime is bound to self so this behaves โas ifโ
it were actually an instance of T that is getting borrowed. If a longer
(unbound) lifetime is needed, use &*my_ptr.ptr()
.
Sourcepub unsafe fn as_mut(&mut self) -> &mut T
๐ฌThis is a nightly-only experimental API. (kernel_ptr
)
pub unsafe fn as_mut(&mut self) -> &mut T
kernel_ptr
)Mutably dereferences the content.
The resulting lifetime is bound to self so this behaves โas ifโ
it were actually an instance of T that is getting borrowed. If a longer
(unbound) lifetime is needed, use &mut *my_ptr.ptr()
.
Trait Implementationsยง
impl<T: ?Sized> Copy for Unique<T>
impl<T: Send + ?Sized> Send for Unique<T>
Unique
pointers are Send
if T
is Send
because the data they
reference is unaliased. Note that this aliasing invariant is
unenforced by the type system; the abstraction using the
Unique
must enforce it.
impl<T: Sync + ?Sized> Sync for Unique<T>
Unique
pointers are Sync
if T
is Sync
because the data they
reference is unaliased. Note that this aliasing invariant is
unenforced by the type system; the abstraction using the
Unique
must enforce it.
Auto Trait Implementationsยง
impl<T> Freeze for Unique<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Unique<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Unpin for Unique<T>where
T: Unpin + ?Sized,
impl<T> UnwindSafe for Unique<T>where
T: RefUnwindSafe + UnwindSafe + ?Sized,
Blanket Implementationsยง
ยงimpl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
ยงimpl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
ยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
ยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
ยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
ยงunsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit
#126799)