trait-obj-list 0.1.2

List of unsized trait objects, stored in a flat array
Documentation
pub use core::ptr::DynMetadata;
pub use core::ptr::Pointee;
pub use core::ptr::from_raw_parts_mut;

pub fn to_raw_parts_mut<T: core::ptr::Pointee + ?Sized>(
	ptr: *mut T,
) -> (*mut (), <T as core::ptr::Pointee>::Metadata) {
	ptr.to_raw_parts_mut()
}

unsafe impl<T: ?Sized, U> FromImpl<U> for T
where
	U: core::marker::Unsize<T>,
{
	fn coerce(&self) -> &T {
		self as &T
	}

	fn coerce_mut(&mut self) -> &mut T {
		self as &mut T
	}
}

/// Implements [`FromImpl`](crate::FromImpl) for all sized types implementing the specified trait.
///
/// ```
/// # use trait_obj_list::impl_from_impl;
/// trait MyTrait {}
/// impl_from_impl!(dyn MyTrait);
/// impl_from_impl!(dyn MyTrait + Send);
/// impl_from_impl!(dyn MyTrait + Send + Sync);
/// ```
#[macro_export]
macro_rules! impl_from_impl {
	(dyn $($rest:tt)*) => {};
}