Packed tuples

My suggestion is pretty simple: add #[repr(C, packed)] tuples. Note that I don’t mean “replace current tuples with packed ones”.

Probable look: ($($type),*)p.

let x: (u16, u8)p = (15, 10)p;
println!("{}", core::mem::size_of_val(&x));

Can you say more about the use case for these?

I would be inclined to think that if layout is at all important, it's usually worth defining a struct and commenting on the design of it — definitely for FFI, and maybe for memory usage optimization. What situations would especially benefit from an unnamed packed type?


Different kinds of low-level stuff - splitting register's data, for example. It is not that necessary, but can make our lives a little bit easier. I anyway am here primarily not to discuss, but to watch the discussion (if anyone is interested). And the only use case of this is boilerplate code reduction.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.