Diffstat (limited to 'src/any.rs')
-rw-r--r--src/any.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/any.rs b/src/any.rs
index ed6c1ef..72a0c5f 100644
--- a/src/any.rs
+++ b/src/any.rs
@@ -23,6 +23,7 @@ pub mod static_wrapper;
use crate::{bijective_higher_ranked_trait, bijective_higher_ranked_type};
use core::{
+ any::TypeId,
marker::{PhantomData, PhantomPinned},
mem::{ManuallyDrop, MaybeUninit},
};
@@ -35,7 +36,7 @@ bijective_higher_ranked_trait! {
}
bijective_higher_ranked_trait! {
- pub type class TypeName[][]: {'static} [for<'lt> MaybeSized::Trait<'lt>]
+ pub type class TypeName[][]: {'static} [for<'lt> MaybeSized::Trait<'lt> + Send]
}
bijective_higher_ranked_type! {
@@ -117,6 +118,14 @@ pub struct LtTypeId<'lt> {
name: &'static str,
}
+#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone, Debug)]
+pub struct ForAnyTypeId {
+ /// The type ID of the name type of the type.
+ name_id: core::any::TypeId,
+
+ name: &'static str,
+}
+
impl<'lt> LtTypeId<'lt> {
/// Get the ID of a type.
///
@@ -129,6 +138,16 @@ impl<'lt> LtTypeId<'lt> {
name: core::any::type_name::<T>(),
}
}
+
+ /// Get the type ID of the static form.
+ ///
+ /// This will be the same for all lifetimes.
+ pub fn as_type_id(&self) -> ForAnyTypeId {
+ ForAnyTypeId {
+ name_id: self.name_id,
+ name: self.name,
+ }
+ }
}
impl<'lt> core::fmt::Display for LtTypeId<'lt> {