Struct Owned
struct Owned<T: ?Sized + Pointable> { ... }
An owned heap-allocated object.
This type is very similar to Box<T>.
The pointer must be properly aligned. Since it is aligned, a tag can be stored into the unused least significant bits of the address.
Implementations
impl<T> Owned<T>
unsafe fn from_raw(raw: *mut T) -> Owned<T>Returns a new owned pointer pointing to
raw.This function is unsafe because improper use may lead to memory problems. Argument
rawmust be a valid pointer. Also, a double-free may occur if the function is called twice on the same raw pointer.Panics
Panics if
rawis not properly aligned.Safety
The given
rawshould have been derived fromOwned, and onerawshould not be converted back byOwned::from_raw()multiple times.Examples
use Owned; let o = unsafe ;fn into_box(self: Self) -> Box<T>Converts the owned pointer into a
Box.Examples
use Owned; let o = new; let b: = o.into_box; assert_eq!;fn new(init: T) -> Owned<T>Allocates
valueon the heap and returns a new owned pointer pointing to it.Examples
use Owned; let o = new;
impl<T: ?Sized + Pointable> Owned<T>
fn init(init: <T as >::Init) -> Owned<T>Allocates
valueon the heap and returns a new owned pointer pointing to it.Examples
use Owned; let o = init;Converts the owned pointer into a
Shared.Examples
use ; let o = new; let guard = &pin; let p = o.into_shared; # unsafe // avoid leakfn tag(self: &Self) -> usizeReturns the tag stored within the pointer.
Examples
use Owned; assert_eq!;fn with_tag(self: Self, tag: usize) -> Owned<T>Returns the same pointer, but tagged with
tag.tagis truncated to be fit into the unused bits of the pointer toT.Examples
use Owned; let o = new; assert_eq!; let o = o.with_tag; assert_eq!;
impl<P, T> Receiver for Owned<T>
impl<T> Any for Owned<T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Owned<T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Owned<T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Owned<T>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> Freeze for Owned<T>
impl<T> From for Owned<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> From for Owned<T>
fn from(t: T) -> Self
impl<T> From for Owned<T>
fn from(b: Box<T>) -> SelfReturns a new owned pointer pointing to
b.Panics
Panics if the pointer (the
Box) is not properly aligned.Examples
use Owned; let o = unsafe ;
impl<T> From for Owned<T>
fn from(t: never) -> T
impl<T> Pointable for Owned<T>
unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> RefUnwindSafe for Owned<T>
impl<T> Send for Owned<T>
impl<T> Sync for Owned<T>
impl<T> ToOwned for Owned<T>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> Unpin for Owned<T>
impl<T> UnsafeUnpin for Owned<T>
impl<T> UnwindSafe for Owned<T>
impl<T, U> Into for Owned<T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Owned<T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Owned<T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T: ?Sized + Pointable> AsMut for Owned<T>
fn as_mut(self: &mut Self) -> &mut T
impl<T: ?Sized + Pointable> AsRef for Owned<T>
fn as_ref(self: &Self) -> &T
impl<T: ?Sized + Pointable> Borrow for Owned<T>
fn borrow(self: &Self) -> &T
impl<T: ?Sized + Pointable> BorrowMut for Owned<T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T: ?Sized + Pointable> Debug for Owned<T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized + Pointable> Deref for Owned<T>
fn deref(self: &Self) -> &T
impl<T: ?Sized + Pointable> DerefMut for Owned<T>
fn deref_mut(self: &mut Self) -> &mut T
impl<T: ?Sized + Pointable> Drop for Owned<T>
fn drop(self: &mut Self)
impl<T: ?Sized + Pointable> Pointer for Owned<T>
fn into_usize(self: Self) -> usizeunsafe fn from_usize(data: usize) -> SelfReturns a new pointer pointing to the tagged pointer
data.Panics
Panics if the data is zero in debug mode.
impl<T: Clone> Clone for Owned<T>
fn clone(self: &Self) -> Self