Tracking Issue for thin_box
· Issue #92791 · rust-lang/rust (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
Feature gate: #![feature(thin_box)]
This is a tracking issue for ThinBox
for making heap allocated DSTs which only occupy 1 pointer on the stack.
Public API
Note: This API is expected to grow to match Box
as necessary over time. The initial API is the minimum needed for basic usage for error handling.
pub struct ThinBox<T: ?Sized> { /* ... */ }
impl ThinBox { pub fn new(value: T) -> Self; }
impl<Dyn: ?Sized> ThinBox { pub fn new_unsize(value: T) -> Self where T: Unsize; }
impl<T: ?Sized + Debug> Debug for ThinBox { /* ... / } impl<T: ?Sized + Display> Display for ThinBox { / ... / } impl<T: ?Sized + Error> Error for ThinBox { / ... / } impl<T: ?Sized> Deref for ThinBox { type Target = T; / ... / } impl<T: ?Sized> DerefMut for ThinBox { / ... / } impl<T: ?Sized> Drop for ThinBox { / ... */ }
unsafe impl<T: ?Sized + Send> Send for ThinBox {} unsafe impl<T: ?Sized + Sync> Sync for ThinBox {}
Steps / History
- Implementation: #Add new ThinBox type for 1 stack pointer wide heap allocated trait objects #90066
- Added
Send
andSync
: Implement Send and Sync for ThinBox #98595 - Final comment period (FCP)
- Stabilization PR
Unresolved Questions
- Can ThinBox be made covariant? (comment)
- Yes, with more opaque type-casting: Make ThinBox covariant in T #98585
- Is
const_allocate
fleshed out and tested enough to justify it being used in thinbox's impl? Does T-lang agree we'll always have some way to procedurally generate allocations in const eval? (in contrast to declaratively via constants, statics or anonymous promoteds)