std::ops::Boxed - Rust (original) (raw)
Trait std::ops::Boxed [−] [src]
pub trait Boxed { type Data; type Place: BoxPlace<Self::Data>; unsafe fn finalize(filled: Self::Place) -> Self; }
🔬 This is a nightly-only experimental API. (placement_new_protocol
#27779)
Core trait for the box EXPR
form.
box EXPR
effectively desugars into:
let mut place = BoxPlace::make_place(); let raw_place = Place::pointer(&mut place); let value = EXPR; unsafe { ::std::ptr::write(raw_place, value); Boxed::finalize(place) }Run
The type of box EXPR
is supplied from its surrounding context; in the above expansion, the result type T
is used to determine which implementation of Boxed
to use, and that<T as Boxed>
in turn dictates determines which implementation of BoxPlace
to use, namely:<<T as Boxed>::Place as BoxPlace>
.
type [Data](#associatedtype.Data)
🔬 This is a nightly-only experimental API. (placement_new_protocol
#27779)
The kind of data that is stored in this kind of box.
type [Place](#associatedtype.Place): [BoxPlace](../../std/ops/trait.BoxPlace.html "trait std::ops::BoxPlace")<Self::[Data](../../std/ops/trait.Boxed.html#associatedtype.Data "type std::ops::Boxed::Data")>
🔬 This is a nightly-only experimental API. (placement_new_protocol
#27779)
The place that will negotiate the storage of the data.
unsafe fn [finalize](#tymethod.finalize)(filled: Self::[Place](../../std/ops/trait.Boxed.html#associatedtype.Place "type std::ops::Boxed::Place")) -> Self
🔬 This is a nightly-only experimental API. (placement_new_protocol
#27779)
Converts filled place into final owning value, shifting deallocation/cleanup responsibilities (if any remain), over to returned instance of Self
and forgetting filled
.
impl<T> Boxed for [Box](../../std/boxed/struct.Box.html "struct std::boxed::Box")<T> type [Data](#associatedtype.Data) = T; type [Place](#associatedtype.Place) = [IntermediateBox](../../std/boxed/struct.IntermediateBox.html "struct std::boxed::IntermediateBox")<T>;