Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
#![feature(rustc_attrs)]
#[rustc_layout_scalar_valid_range_start(0)]
#[rustc_layout_scalar_valid_range_end(2147483647)]
#[repr(transparent)]
struct NonNegativeI32(i32);
struct T(u32, NonNegativeI32, u32);
enum U<X> {
X(u16, T),
Y(X),
}
enum V<X> {
X(U<X>),
Y([u32; 3]),
}
fn main() {
use std::mem;
dbg!(mem::size_of::<U<()>>());
dbg!(mem::size_of::<V<()>>());
dbg!(mem::size_of::<U<u32>>());
dbg!(mem::size_of::<V<u32>>());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.