Struct thinbox::ThinBox [−][src]
pub struct ThinBox<T: ?Sized> { /* fields omitted */ }
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.
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.
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 ofBox::<U>::into_raw
as *mut ()
orThinBox::<U>::into_raw
whereU
safe totransmute
intoT
.- The alignment requirements of
T
must not be more strict than those ofU
. - It must be generally safe to dereference
raw
, keeping in mind thatraw
does not actually point to()
and does not necessarily even point to aU
.
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.
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.
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.
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.
Supplanted by the fat_type crate.
👎 Deprecated: Supplanted by the fat_type crate.
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 aU
.
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.
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.
Supplanted by the fat_type crate.
👎 Deprecated: Supplanted by the fat_type crate.
Supplanted by the fat_type crate.
👎 Deprecated: Supplanted by the fat_type crate.
Supplanted by the fat_type crate.
Moves the owned value out of a Sized
ThinBox
.
Trait Implementations
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for ThinBox<T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more