trait-obj-list 0.1.2

List of unsized trait objects, stored in a flat array
Documentation
#![allow(unused)]

use std::any::Any;
use std::any::TypeId;

macro_rules! for_each_list_type {
	(
		$(
			$(#[$meta:meta])*
			fn $testname:ident<$typ:ident>() $body:block
		)*
	) => {
		$(
			::pastey::paste!{
				$(#[$meta])*
				fn [< $testname _single_linked >]() {
					type $typ = trait_obj_list::types::SingleLinked;
					$body
				}
			}
			::pastey::paste!{
				$(#[$meta])*
				fn [< $testname _double_linked >]() {
					type $typ = trait_obj_list::types::DoubleLinked;
					$body
				}
			}
		)*
	};
}
pub(crate) use for_each_list_type;

#[track_caller]
pub(crate) fn assert_any_eq<T: Any + PartialEq + std::fmt::Debug>(a: &dyn Any, b: T) {
	let Some(a) = a.downcast_ref::<T>() else {
		panic!(
			"Expected typeid {:?}, got {:?} (i32: {:?}, i64: {:?}, i16: {:?})",
			TypeId::of::<T>(),
			(*a).type_id(),
			TypeId::of::<i32>(),
			TypeId::of::<i64>(),
			TypeId::of::<i16>(),
		);
	};
	assert_eq!(a, &b);
}