Rust: the trait with trait parametr – bound is not satisfied

I was trying to push to Vec object which is implementing trait with trait parameter.

trait IRequest{

}

trait IRequestHandler<T>
where T: IRequest
{
    fn handle(&self, request: T);
}

pub struct CreateTodoRequest();

impl IRequest for CreateTodoRequest { }

pub struct CreateTodoRequestHandler();

impl IRequestHandler<CreateTodoRequest> for CreateTodoRequestHandler
{
    fn handle(&self, request: CreateTodoRequest) {
        
    }
}

fn main() {

    let request = CreateTodoRequest{};
    let handler = CreateTodoRequestHandler();
    let mut handlers : Vec<&dyn IRequestHandler<dyn IRequest>> = Vec::new();

    handlers.push(&handler); 
    
}

I got following error:

the trait bound CreateTodoRequestHandler: IRequestHandler<dyn IRequest> is not satisfied
the following implementations were found:
<CreateTodoRequestHandler as IRequestHandler>
required for the cast to the object type `dyn IRequestHandler

When I written IRequestHandler without paramter I could to cast it and push to Vec. Problem is apearing when trait has parameter.

Is it possible to cast object to trait with parameter that they implemented?

Go to Source
Author: pager_dev