4 ms·
Sure, I meant: Rust guarantees to optimize the following types T such that Option<T> has the same size as T: Box<U> &U &mut U fn, extern "C" f
by deepsun 5y ago
Sure, I meant:
Rust guarantees to optimize the following types T such that Option<T> has the same size as T:
Box<U>
&U
&mut U
fn, extern "C" fn
num::NonZero*
ptr::NonNull<U>
#[repr(transparent)] struct around one of the types in this list.
UPDATE: Or, better per your example:
struct T {i: i32} takes the same size as i32: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b95205ebeff6ddbe08a0b9d9900bb260 https://play.rust-lang.org/?version=stable&mode=debug&editio...