#![cfg(any(test, doc))]
pub(crate) fn eq_slice_buf<T>(a: &[T], b: &[T]) -> bool {
a.as_ptr() == b.as_ptr() && a.len() == b.len()
}
#[doc(alias = "assert_fits_in")]
macro_rules! assert_fits_in_impl {
($expr: expr, $ty: ty) => {
assert!(<$ty>::try_from($expr).is_ok(), "{} does not fit into {}", stringify!($expr), stringify!($ty))
};
($expr: expr, $ty: ty, $($arg:tt)+) => {
assert!(<$ty>::try_from($expr).is_ok(), $($arg)+)
};
}
#[doc(alias = "test_for_each_type")]
macro_rules! test_for_each_type_impl {
($test: ident, []) => {};
($test: ident, [$ty: ty]) => {
loop {
$test!($ty);
break;
}
};
($test: ident, [$ty: ty, $($rest: ty),+]) => {
$crate::test_utils::test_for_each_type!($test, [$ty]);
$crate::test_utils::test_for_each_type!($test, [$($rest),+]);
};
($test: ident, [$ty: ty,]) => {
$crate::test_utils::test_for_each_type!($test, [$ty]);
};
($test: ident, [$ty: ty, $($rest: ty),+,]) => {
$crate::test_utils::test_for_each_type!($test, [$ty, $($rest),+]);
};
}
#[doc(alias = "test_recommended_default")]
macro_rules! test_recommended_default_impl {
($ty: ty) => {{
let value1 = <$ty>::new();
let value2 = <$ty>::default();
assert_eq!(value1, value2);
}};
}
pub(crate) use assert_fits_in_impl as assert_fits_in;
pub(crate) use test_for_each_type_impl as test_for_each_type;
pub(crate) use test_recommended_default_impl as test_recommended_default;
mod tests;