"Cannot find type `M` in this scope

I am having a little trouble using Rocket, I am not sure this problem is related to Rocket.

pub struct Webhook<M: MyTrait> {
    address: String,
    port: i16,
    xxmm: Arc<M>,
}
impl<M: MyTrait + 'static> Webhook<M> {
    pub async fn start(&self) -> anyhow::Result<()> {
        rocket::build()
            .manage(self.xxmm.clone())
            .mount(
                "/",
                routes![get_root]
            )
            .launch()
            .await?;

        Ok(())
    }
}

#[get("/")]
fn get_root<M>(
    xxmm: &State<Arc<M>>, // Here I got the error: cannot find type `M` in this scope
    _header_check: GetHeadersCheck,
) -> (ContentType, Json<MyObj>)
where
    M: MyTrait,
{
    todo!();
}

I think Rocket does not support generic handler.

I suspected that. But did not find a certain info. If this was the cause, the error message was kind of confusing.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.