use core::panic::{RefUnwindSafe, UnwindSafe};
#[derive(Copy, Clone)]
enum Void {}
#[allow(missing_debug_implementations)]
#[repr(packed)]
pub struct Ignore<T: ?Sized>([*const T; 0], Void);
impl<T: ?Sized> Copy for Ignore<T> {}
impl<T: ?Sized> Clone for Ignore<T> {
fn clone(&self) -> Self {
*self
}
}
unsafe impl<T: ?Sized> Send for Ignore<T> {}
unsafe impl<T: ?Sized> Sync for Ignore<T> {}
impl<T: ?Sized> UnwindSafe for Ignore<T> {}
impl<T: ?Sized> RefUnwindSafe for Ignore<T> {}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn enum_with_ignored_variant_is_zero_sized() {
enum Test {
_A,
_B(Ignore<u64>),
}
assert_eq!(core::mem::size_of::<Test>(), 0);
}
}