#[cfg(feature = "copy")]
macro_rules! default {
(#[inline] $($fn:tt)*) => { #[inline] default $($fn)* };
($($fn:tt)*) => { default $($fn)* };
}
#[cfg(not(feature = "copy"))]
macro_rules! default {
(#[inline] $($fn:tt)*) => { #[inline] $($fn)* };
($($fn:tt)*) => { $($fn)* };
}
#[macro_export]
macro_rules! out_field {
($out:ident.$field:tt) => {{
#[allow(unused_unsafe)]
unsafe {
let fo = ::core::ptr::addr_of_mut!((*$out).$field);
(fo.cast::<u8>().offset_from($out.cast::<u8>()) as usize, fo)
}
}};
}
#[macro_export]
macro_rules! from_archived {
($expr:expr) => {{
#[cfg(not(any(feature = "archive_le", feature = "archive_be")))]
{
$expr
}
#[cfg(any(feature = "archive_le", feature = "archive_be"))]
{
($expr).value()
}
}};
}
#[cfg(any(feature = "archive_le", feature = "archive_be"))]
pub use crate::rend::NativeEndian;
#[macro_export]
macro_rules! to_archived {
($expr:expr) => {{
#[cfg(not(any(feature = "archive_le", feature = "archive_be")))]
{
$expr
}
#[cfg(feature = "archive_le")]
{
$crate::macros::NativeEndian { value: $expr }.to_le()
}
#[cfg(feature = "archive_be")]
{
$crate::macros::NativeEndian { value: $expr }.to_be()
}
}};
}
#[cfg(not(any(feature = "size_16", feature = "size_32", feature = "size_64")))]
core::compile_error!(r#"one of ["size_16", "size_32", or "size_64"] features must be enabled"#);
#[cfg(all(feature = "size_16", feature = "size_32"))]
core::compile_error!(
"\"size_16\" and \"size_32\" are mutually-exclusive features. You may need to set \
`default-features = false` or compile with `--no-default-features`."
);
#[cfg(all(feature = "size_16", feature = "size_64"))]
core::compile_error!(
"\"size_16\" and \"size_64\" are mutually-exclusive features. You may need to set \
`default-features = false` or compile with `--no-default-features`."
);
#[cfg(all(feature = "size_32", feature = "size_64"))]
core::compile_error!(
"\"size_32\" and \"size_64\" are mutually-exclusive features. You may need to set \
`default-features = false` or compile with `--no-default-features`."
);
#[cfg(feature = "size_16")]
macro_rules! pick_size_type {
($s16:ty, $s32:ty, $s64:ty) => {
$s16
};
($s16:ty, $s32:ty, $s64:ty,) => {
pick_size_type!($s16, $s32, $s64)
};
}
#[cfg(feature = "size_32")]
macro_rules! pick_size_type {
($s16:ty, $s32:ty, $s64:ty) => {
$s32
};
($s16:ty, $s32:ty, $s64:ty,) => {
pick_size_type!($s16, $s32, $s64)
};
}
#[cfg(feature = "size_64")]
macro_rules! pick_size_type {
($s16:ty, $s32:ty, $s64:ty) => {
$s64
};
($s16:ty, $s32:ty, $s64:ty,) => {
pick_size_type!($s16, $s32, $s64)
};
}