Maybe you could create a wrapper type around your allocation (say Array<T>) and implement Drop and Deref<Target=[T]> for it and use an Array<T> instead of a Box<[T]>.
Does that special allocation come from Rust btw? Because I think you cannot have Rust free it if it was created by (for example) a C allocator.
Nah, it's internal to Rust. I'm working on a Vec-like type and I noticed that Vec supports into_boxed_slice() which I'll be able unable to implement, unfortunately.
Well, I suppose I can't argue with that.
Still, there might be utility in Box someday supporting extra Drop logic. Or maybe when the Allocators WG produces more facilities.
The idiomatic way to tweak how something is destroyed in Rust is to implement your own destructor. Allowing both a custom deleter and a Drop impl sounds like a great way to confuse people, so I'd go with either a custom smart pointer or use a wrapper around the [T] that implements Deref.
How do you go about constructing one of those? There are helpers to produce Box<[T]>, but it’s not obvious to me how to build the slice inside a tuple.
There aren't really any good ways. Afaik, currently the only way is to make a Box<(Head, [Tail; n])> for some n and then just coerce it. Additionally, you can't do it with tuples, but you can with a struct: