SeaBoxIn

Struct SeaBoxIn 

Source
pub struct SeaBoxIn<T, A: Allocator> { /* private fields */ }
Expand description

Owned, aligned pointer to a T, which is freed on Drop.

The allocator is pluggable - see Allocator.

#[repr(transparent)] such that Option<SeaBox<T>> has the same layout as *mut T.

Implementations§

Source§

impl<T, A: Allocator> SeaBoxIn<T, A>

Source

pub fn new(t: T) -> Self

Available on crate feature alloc only.

Copy t into the heap.

Source

pub fn try_new(t: T) -> Result<Self, AllocError>

Source

pub unsafe fn try_emplace( f: impl FnOnce(&mut MaybeUninit<T>), ) -> Result<Self, AllocError>

§Safety
  • Must initialize the given memory.

Note that if T is a ZST, the passed in memory is ephemeral.

Source

pub fn unbox(self) -> T

Source

pub const unsafe fn from_raw(ptr: *mut T) -> Self

§Safety
  • Must have been allocated by A.
  • Must be a valid T.
  • This must be the only pointer to the allocation.
Source

pub const fn into_raw(this: Self) -> *mut T

Trait Implementations§

Source§

impl<T, A: Allocator> AsMut<T> for SeaBoxIn<T, A>

Source§

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

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T, A: Allocator> AsRef<T> for SeaBoxIn<T, A>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, A: Allocator> Borrow<T> for SeaBoxIn<T, A>

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T, A: Allocator> BorrowMut<T> for SeaBoxIn<T, A>

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T: Debug, A: Allocator> Debug for SeaBoxIn<T, A>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T, A: Allocator> Deref for SeaBoxIn<T, A>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, A: Allocator> DerefMut for SeaBoxIn<T, A>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: Display, A: Allocator> Display for SeaBoxIn<T, A>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T, A: Allocator> Drop for SeaBoxIn<T, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: Hash, A: Allocator> Hash for SeaBoxIn<T, A>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Ord, A: Allocator> Ord for SeaBoxIn<T, A>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T1, T2, A1: Allocator, A2: Allocator> PartialEq<SeaBoxIn<T2, A2>> for SeaBoxIn<T1, A1>
where T1: PartialEq<T2>,

Source§

fn eq(&self, other: &SeaBoxIn<T2, A2>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T1, T2, A1: Allocator, A2: Allocator> PartialOrd<SeaBoxIn<T2, A2>> for SeaBoxIn<T1, A1>
where T1: PartialOrd<T2>,

Source§

fn partial_cmp(&self, other: &SeaBoxIn<T2, A2>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Eq, A: Allocator> Eq for SeaBoxIn<T, A>

Source§

impl<T: Send, A: Allocator + Send> Send for SeaBoxIn<T, A>

Source§

impl<T: Sync, A: Allocator + Sync> Sync for SeaBoxIn<T, A>

Auto Trait Implementations§

§

impl<T, A> Freeze for SeaBoxIn<T, A>

§

impl<T, A> RefUnwindSafe for SeaBoxIn<T, A>

§

impl<T, A> Unpin for SeaBoxIn<T, A>
where T: Unpin, A: Unpin,

§

impl<T, A> UnwindSafe for SeaBoxIn<T, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.