Diffstat (limited to 'src/any.rs')
-rw-r--r--src/any.rs72
1 files changed, 33 insertions, 39 deletions
diff --git a/src/any.rs b/src/any.rs
index 78190df..9dc5115 100644
--- a/src/any.rs
+++ b/src/any.rs
@@ -3,7 +3,7 @@
//! The `AnyTrait` trait provides dynamic upcasting to trait objects.
pub mod indirect;
-// mod static_wrapper;
+mod static_wrapper;
mod type_name_id;
use crate::{
@@ -12,7 +12,7 @@ use crate::{
};
use core::marker::PhantomData;
-// pub use static_wrapper::*;
+pub use static_wrapper::*;
pub use type_name_id::*;
#[cfg(all(feature = "alloc", not(feature = "std")))]
@@ -46,50 +46,44 @@ higher_ranked_type! {
where {
T: ?Sized + TypeName::LowerType<'a, 'ctx>
};
+ }
+}
+
+pub struct MutHrt<T: ?Sized>(Marker<T>);
- impl['a, 'ctx, T] type HigherRankedAll['a, 'ctx] for &'a T =
- RefHrt<TypeName::HigherRankedAll<'a, 'ctx, T>>
+higher_ranked_type! {
+ impl TypeName {
+ impl['a, 'ctx, T] type T['a, 'ctx] for MutHrt<T> =
+ &'a mut TypeName::T<'a, 'ctx, T>
where {
- T: ?Sized + TypeName::LowerType<'a, 'ctx>
+ T: ?Sized + TypeName::LowerForLt<'a, 'ctx, TypeName::Bound<'a, 'ctx>>,
+ TypeName::T<'a, 'ctx, T>: 'a
+ };
+
+ impl['a, 'ctx, T] type HigherRanked['a, 'ctx] for &'a mut T =
+ MutHrt<TypeName::HigherRanked<'a, 'ctx, T>>
+ where {
+ T: ?Sized + TypeName::RaiseForLt<'a, 'ctx, TypeName::Bound<'a, 'ctx>>
};
}
}
-pub struct MutHrt<T: ?Sized>(Marker<T>);
+#[cfg(feature = "alloc")]
+higher_ranked_type! {
+ impl TypeName {
+ impl['a, 'ctx, T] type T['a, 'ctx] for Box<T> =
+ Box<TypeName::T<'a, 'ctx, T>>
+ where {
+ T: ?Sized + TypeName::LowerForLt<'a, 'ctx, TypeName::Bound<'a, 'ctx>>,
+ };
-// higher_ranked_type! {
-// impl TypeName {
-// impl['a, 'ctx, T] type T['a, 'ctx] for MutHrt<T> =
-// &'a mut TypeName::T<'a, 'ctx, T>
-// where {
-// T: ?Sized + TypeName::LowerForLt<'a, 'ctx, TypeName::Bound<'a, 'ctx>>,
-// TypeName::T<'a, 'ctx, T>: 'a
-// };
-//
-// impl['a, 'ctx, T] type HigherRanked['a, 'ctx] for &'a mut T =
-// MutHrt<TypeName::HigherRanked<'a, 'ctx, T>>
-// where {
-// T: ?Sized + TypeName::RaiseForLt<'a, 'ctx, TypeName::Bound<'a, 'ctx>>
-// };
-// }
-// }
-
-// #[cfg(feature = "alloc")]
-// higher_ranked_type! {
-// impl TypeName {
-// impl['a, 'ctx, T] type T['a, 'ctx] for Box<T> =
-// Box<TypeName::T<'a, 'ctx, T>>
-// where {
-// T: ?Sized + TypeName::LowerForLt<'a, 'ctx, TypeName::Bound<'a, 'ctx>>,
-// };
-//
-// impl['a, 'ctx, T] type HigherRanked['a, 'ctx] for Box<T> =
-// Box<TypeName::HigherRanked<'a, 'ctx, T>>
-// where {
-// T: ?Sized + TypeName::RaiseForLt<'a, 'ctx, TypeName::Bound<'a, 'ctx>>
-// };
-// }
-// }
+ impl['a, 'ctx, T] type HigherRanked['a, 'ctx] for Box<T> =
+ Box<TypeName::HigherRanked<'a, 'ctx, T>>
+ where {
+ T: ?Sized + TypeName::RaiseForLt<'a, 'ctx, TypeName::Bound<'a, 'ctx>>
+ };
+ }
+}
/// Dynamic trait lookup.
///