Struct thinbox::ThinBox[][src]

pub struct ThinBox<T: ?Sized> { /* fields omitted */ }
👎 Deprecated:

Supplanted by the fat_type crate.

Expand description

A consistently-sized pointer type for heap allocation.

See the crate documentation for an example using ThinBox.

Implementations

👎 Deprecated:

Supplanted by the fat_type crate.

Creates a new ThinBox by unsizing a value and placing it on the heap.

👎 Deprecated:

Supplanted by the fat_type crate.

Recovers ThinBox ownership of a boxed pointee.

Along with into_raw, this function provides one of the core operations which makes ThinBox useful for interoperation with foreign functions.

Safety

  • raw must be result of Box::<U>::into_raw as *mut () or ThinBox::<U>::into_raw where U safe to transmute into T.
  • The alignment requirements of T must not be more strict than those of U.
  • It must be generally safe to dereference raw, keeping in mind that raw does not actually point to () and does not necessarily even point to a U.

The first requirement implies that:

Furthermore, support for Box::<U>::into_raw is not guaranteed to be preserved across major versions of thinbox.

👎 Deprecated:

Supplanted by the fat_type crate.

Converts the ThinBox to a single-pointer-sized representation.

Along with from_raw, this function provides one of the core operations which makes ThinBox useful for interoperation with foreign functions.

Notes

It is not safe to dereference this representation. The type of the pointee depends not only on T but also on whether or not T is Sized.

👎 Deprecated:

Supplanted by the fat_type crate.

Obtains a raw pointer to the boxed value.

The pointee remains owned by the ThinBox. If you wish to relinquish ownership, use into_raw or leak.

Notes

This method returns a raw mutable pointer, which is dangerous to use. However ThinBox is guaranteed to never store an internal reference to its owned value so dereferencing this pointer does not necessarily cause undefined behavior.

👎 Deprecated:

Supplanted by the fat_type crate.

Leaks the contained value in a manner similar to Box::leak.

Unlike Box::leak, if T is unsized it is not valid to pass the returned reference to Box::from_raw or ThinBox::from_raw.

To restore a ThinBox from the reference produced by this function use unleak.

👎 Deprecated:

Supplanted by the fat_type crate.

Restores a ThinBox from a reference created by leak.

Safety

  • If T is Sized, this method behaves as-if from_raw was invoked on leaked.
  • If T is unsized, leaked must have been produced by calling ThinBox::<T>::leak. Any difference in the ThinBox type signatures involved will result in undefined behavior in all but the most contrived of cases.
👎 Deprecated:

Supplanted by the fat_type crate.

Moves the owned value into dest by transmuting it into the Sized type U.

Notes

  • The value pointed to by dest, if any, is not dropped.
  • The owned value of the ThinBox does not need to be properly aligned as a U.

Safety

Immediate undefined behavior occurs if U is larger in size than the owned value or if dest is not valid for writes. Otherwise any undefined behavior is deferred to later operations which dereference dest and thereby observe the result of the transmutation.

👎 Deprecated:

Supplanted by the fat_type crate.

Creates a new ThinBox by moving a Sized value to the heap.

Notes

Doing this passes up your opportunity to coerce the value to an unsized type, thereby defeating most of the usefulness of ThinBox. Instead, you should consider using Box unless you are constrained by some other code which requires instances of ThinBox.

👎 Deprecated:

Supplanted by the fat_type crate.

Converts a Sized Box into a ThinBox.

Notes

This operation is zero-cost. 💸

👎 Deprecated:

Supplanted by the fat_type crate.

Converts a Sized ThinBox into a Box.

Notes

This operation is zero-cost. 💸

👎 Deprecated:

Supplanted by the fat_type crate.

Moves the owned value out of a Sized ThinBox.

Trait Implementations

Performs the conversion.

Performs the conversion.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Performs the conversion.

Feeds this value into the given Hasher. Read more

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

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.