Skip to main content

BoxA

Struct BoxA 

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

A pointer type that uniquely owns a heap allocation of type T.

dyn values can be boxed using the unsize_box macro.

Implementations§

Source§

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

Source

pub fn new(t: T) -> Self
where A: Default,

Allocates memory then places t into it.

Source

pub fn new_in(t: T, a: A) -> Self

Allocates memory in the given allocator then places t into it.

Source

pub fn from_slice_in(s: &[T], a: A) -> BoxA<[T], A>
where T: Clone,

Allocates memory in the given allocator then clones s into it.

Source§

impl<T: ?Sized, A: Allocator> BoxA<T, A>

Source

pub fn from_str(s: &str) -> BoxA<str, A>
where A: Default,

Allocates memory then copies s into it.

Source

pub fn from_str_in(s: &str, a: A) -> BoxA<str, A>

Allocates memory in the given allocator then copies s into it.

Note: there is currently no equivalent in the standard library.

Source

pub fn into_raw_with_allocator(b: Self) -> (*mut T, A)

Convert into raw pointer and allocator.

Source

pub unsafe fn from_raw_in(p: *mut T, a: A) -> Self

Create from raw pointer in specified allocator.

§Safety

This function is unsafe because improper use may lead to memory problems. For example, a double-free may occur if the function is called twice on the same raw pointer.

The non-null pointer must point to a block of memory allocated by a.

Trait Implementations§

Source§

impl<T: ?Sized, A: Allocator> Borrow<T> for BoxA<T, A>

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T: ?Sized, A: Allocator> BorrowMut<T> for BoxA<T, A>

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<A: Allocator + Clone> Clone for BoxA<str, A>

Source§

fn clone(&self) -> BoxA<str, A>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Clone, A: Allocator + Clone> Clone for BoxA<T, A>

Source§

fn clone(&self) -> BoxA<T, A>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: ?Sized + Debug, A: Allocator> Debug for BoxA<T, A>

Source§

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

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

impl<T: ?Sized, A: Allocator> Deref for BoxA<T, A>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: ?Sized, A: Allocator> DerefMut for BoxA<T, A>

Source§

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

Mutably dereferences the value.
Source§

impl<'de, T, A> Deserialize<'de> for BoxA<T, A>
where T: Deserialize<'de>, A: Allocator + Default,

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: ?Sized + Display, A: Allocator> Display for BoxA<T, A>

Source§

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

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

impl<T: ?Sized, A: Allocator> Drop for BoxA<T, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: ?Sized + Eq, A: Allocator> Eq for BoxA<T, A>

Source§

impl<T: ?Sized + Hash, A: Allocator> Hash for BoxA<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: ?Sized + Ord, A: Allocator> Ord for BoxA<T, A>

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl<T: ?Sized + PartialEq, A: Allocator> PartialEq for BoxA<T, A>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for BoxA<T, A>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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: ?Sized + Send, A: Allocator + Send> Send for BoxA<T, A>

Source§

impl<T, A> Serialize for BoxA<T, A>
where T: Serialize, A: Allocator,

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: ?Sized + Sync, A: Allocator + Sync> Sync for BoxA<T, A>

Auto Trait Implementations§

§

impl<T, A> Freeze for BoxA<T, A>
where A: Freeze, T: ?Sized,

§

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

§

impl<T, A> Unpin for BoxA<T, A>
where A: Unpin, T: ?Sized,

§

impl<T, A> UnsafeUnpin for BoxA<T, A>
where A: UnsafeUnpin, T: ?Sized,

§

impl<T, A> UnwindSafe for BoxA<T, A>
where A: UnwindSafe, T: RefUnwindSafe + ?Sized,

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> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

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

Uses borrowed data to replace owned data, usually by cloning. Read more
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.