Diffstat (limited to 'src/mock/builder.rs')
| -rw-r--r-- | src/mock/builder.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/mock/builder.rs b/src/mock/builder.rs index 31c1623..9fef358 100644 --- a/src/mock/builder.rs +++ b/src/mock/builder.rs @@ -1,7 +1,7 @@ use mockall::mock; use crate::{ - any::{AnyTrait, IndirectLtAny, LtTypeId, Mut, Ref}, + any::{indirect, AnyTrait, AnyTraitObject, TypeNameId}, effect::{Effect, Future}, mock::{ContextLock, StaticTypeMap}, protocol::Visitor, @@ -12,15 +12,13 @@ use self::__mock_MockBuilder::__from_seed::Context; use super::ContextGuard; -use crate::any::ForAnyTypeId; - mock! { pub Builder<Seed: 'static, Value: 'static, Error: 'static> { pub fn from_seed(seed: Seed) -> Self; pub fn build(self) -> Result<Value, Error>; - pub fn traits(&self, id: ForAnyTypeId) -> &Option<Box<dyn for<'ctx> AnyTrait<'ctx> + Send>>; - pub fn traits_mut(&mut self, id: ForAnyTypeId) -> &mut Option<Box<dyn for<'ctx> AnyTrait<'ctx> + Send>>; + pub fn traits(&self, id: TypeNameId) -> &Option<Box<dyn for<'ctx> AnyTrait<'ctx> + Send>>; + pub fn traits_mut(&mut self, id: TypeNameId) -> &mut Option<Box<dyn for<'ctx> AnyTrait<'ctx> + Send>>; } } @@ -73,26 +71,24 @@ impl<'ctx, Seed: Send, Value: Send, Error: Send, E: Effect<'ctx>> Builder<'ctx, impl<'ctx, Seed, Value, Error> AnyTrait<'ctx> for MockBuilder<Seed, Value, Error> { #[track_caller] - fn upcast_to_id<'a>(&'a self, id: LtTypeId<'ctx>) -> Option<IndirectLtAny<'a, 'ctx, Ref>> + fn upcast_to_id<'a>(&'a self, id: TypeNameId) -> Option<AnyTraitObject<'a, 'ctx, indirect::Ref>> where 'ctx: 'a, { // Find the first trait handler that wants to upcast. - self.traits(id.as_type_id()) - .as_ref() - .and_then(|t| t.upcast_to_id(id)) + self.traits(id).as_ref().and_then(|t| t.upcast_to_id(id)) } #[track_caller] - fn upcast_to_id_mut<'a: 'b, 'b>( + fn upcast_to_id_mut<'a>( &'a mut self, - id: LtTypeId<'ctx>, - ) -> Option<IndirectLtAny<'b, 'ctx, Mut>> + id: TypeNameId, + ) -> Option<AnyTraitObject<'a, 'ctx, indirect::Mut>> where 'ctx: 'a, { // Find the first trait handler that wants to upcast. - self.traits_mut(id.as_type_id()) + self.traits_mut(id) .as_mut() .and_then(|t| t.upcast_to_id_mut(id)) } |