3 ms·
> As far as I can tell, any time you want to rely on the exact binary layout of something in memory, you need unsafe. As a corollary, any time you want to bit c
by pcwalton 2y ago
> As far as I can tell, any time you want to rely on the exact binary layout of something in memory, you need unsafe. As a corollary, any time you want to bit cast from one type to another, you need unsafe.
No, that's what bytemuck is for. If bytemuck didn't exist, sure, I'd be using a lot of unsafe.
- pclmulqdq 2y agoBytemuck handles the latter, not the former. In the applications I am working on, both matter.
- pcwalton 2y agoI can't quite parse your statement, but if you mean that bytemuck doesn't let you "rely on the exact binary layout of something in memory", then yes, it does: it lets you cast from a Pod type to another Pod type, which exposes the memory layout of both types.