Struct Unique

Source
pub struct Unique<T: ?Sized> {
    pointer: NonNull<T>,
    _marker: PhantomData<T>,
}
๐Ÿ”ฌThis is a nightly-only experimental API. (kernel_ptr)

Fieldsยง

ยงpointer: NonNull<T>
๐Ÿ”ฌThis is a nightly-only experimental API. (kernel_ptr)
ยง_marker: PhantomData<T>
๐Ÿ”ฌThis is a nightly-only experimental API. (kernel_ptr)

Implementationsยง

Sourceยง

impl<T: Sized> Unique<T>

Source

pub fn empty() -> Self

๐Ÿ”ฌThis is a nightly-only experimental API. (kernel_ptr)

Creates a new Unique that is dangling, but well-aligned.

This is useful for initializing types which lazily allocate, like Vec::new does.

Sourceยง

impl<T: ?Sized> Unique<T>

Source

pub const unsafe fn new(ptr: *mut T) -> Unique<T>

๐Ÿ”ฌThis is a nightly-only experimental API. (kernel_ptr)

Creates a new Unique.

ยงSafety

ptr must be non-null.

Source

pub fn as_ptr(self) -> *mut T

๐Ÿ”ฌThis is a nightly-only experimental API. (kernel_ptr)

Acquires the underlying *mut pointer.

Source

pub unsafe fn as_ref(&self) -> &T

๐Ÿ”ฌThis is a nightly-only experimental API. (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().

Source

pub unsafe fn as_mut(&mut self) -> &mut T

๐Ÿ”ฌThis is a nightly-only experimental API. (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ยง

Sourceยง

impl<T: ?Sized> Clone for Unique<T>

Sourceยง

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0ยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl<T: ?Sized> Pointer for Unique<T>

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Sourceยง

impl<T: ?Sized> Copy for Unique<T>

Sourceยง

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.

Sourceยง

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 T
where T: 'static + ?Sized,

ยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
ยง

impl<T> Borrow<T> for T
where T: ?Sized,

ยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
ยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

ยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
ยง

impl<T> CloneToUninit for T
where T: Clone,

ยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
ยง

impl<T> From<T> for T

ยง

fn from(t: T) -> T

Returns the argument unchanged.

ยง

impl<T, U> Into<U> for T
where U: From<T>,

ยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

ยง

impl<T> ToOwned for T
where T: Clone,

ยง

type Owned = T

The resulting type after obtaining ownership.
ยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
ยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
ยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

ยง

type Error = Infallible

The type returned in the event of a conversion error.
ยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
ยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

ยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
ยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.