I think you could get away with allocating `Vec<T>` (where `T` has the alignment you want), then using {into,from}_raw_parts to convert between Vec<u8> as you need it. But you cannot realloc or drop with the Vec<u8>.
-
-
Show this thread
-
N.B. In my case, T = {u8, u16, u32, u64}, so it's safe to re-interpret as bytes. I don't need a fully general solution for any T. (Of course, that is certainly not possible anyway!)
Show this thread
End of conversation
New conversation -
-
-
The default allocator on the platform is *likely* to always give you something 8/16-byte aligned, right? You can replace the global allocator, to be sure. Apart from that I agree with how you see the problem.
-
Maybe. Dunno. I would definitely want a guarantee though and do not want to rely on a particular allocator since this is in a library.
- 4 more replies
New conversation -
-
-
I wish this were possible also but I think it's not, since you'll end up passing the wrong Layout to dealloc.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.