I've got a trait IDriven<T>
which defines a method create(&self, entity: T)
. I've implemented this trait for multiple types on the struct Respository
- now I wish to call create
for a specific type on an instance of Repository
- but I can't figure out how to properly call it?
I've got this:
impl IService for ScriptCreateSvc {
type Input = Script;
type Output = Script;
type Entity = Script;
fn execute(respository: &impl IDriven<Script>, script: Script) -> Result<Script, DomainError> {
// This works, but if I include more implementation bounds in the function signature i need to call a specific impl.
let s1 = respository.create(script)?;
// I've been trying to call a specific implementation of IDriven<T> like this, but it complains the trait is not satisfied, see below
let s2 = IDriven::<Script>::create(&respository, script);
!unimplemented()
}
}
In my second attempt s2
above I get this compiler error:
the trait
IDriven<entities::tag::Tag>
is not implemented for&impl IDriven<Strategy>
How can IDriven<Tag>
not be implemented for an anonymous type that implements that trait for that concrete type..?