Is there a way to get a Vec<u8> with an alignment (known at compile time) greater than 1? Preferably, where all subsequent uses of the Vec<u8>, including pushing and drop, are safe and correct. #rustlang (I *think* the answer is no, but it would simplify a problem I have.)
-
-
Does it have to be Vec<u8> exactly? Otherwise, it shouldn't be too hard to make an AlignedBytes<T> that presents an API like Vec<u8>.
-
I think that's probably similar to my follow-up tweet, yeah. In my case, this is about avoiding the addition of another type parameter. I guess given that choice and writing more unsafe, I'll probably go with the additional type parameter.
End of conversation
New conversation -
-
-
Would const generics make that possible? Make it generic over N: usize, have T=[u8; 2^N] internally. (I have not played with cg yet, I'm just wildly guessing)
-
I don't think so. Note that I'm talking about alignment here. Not length. [u8; 2^N] still has an alignment of 1. Either way, I would want something that works on stable. :)
End of conversation
New conversation -
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.