Description
Assuming #8981 is completed (which it looks like it will be), I think we should consider representing slices using 3 words. The goal would be to have an invariant that every instance of the type ~T
has the same representation as &T
, for all T
(in a DST world, T
includes types like [U]
).
This would simplify trans, but it would also enable us to write a function like borrow_all
:
fn borrow_all<'a,T>(x: &'a [~T]) -> &'a [&'a T] { unsafe { transmute(x) } }
The main sticking point is that it would require an extra unused word in slices that takes the place of "capacity" (aka "alloc") for normal vectors. It's unclear what performance impact this would have and presumably merits some investigation.
I envisioned this "deep borrowing" as explicit, though it's conceivable we could integrate this into coercion. But in general I sort of want to remove autocoercion wherever possible.