use actix_web::{get, web, App}; trait UserRepository { fn get_user(&self) -> u64; } #[derive(Clone)] struct UserClient; impl UserRepository for UserClient { fn get_user(&self) -> u64 { 99 } } #[derive(Clone)] struct Flag; #[get("/")] async fn index(client: web::Data) -> String where T: UserRepository + Send + Sync + 'static, { client.get_ref().get_user().to_string() } #[get("/multi")] async fn multi(client: web::Data, _flag: web::Data) -> String where T: UserRepository + Send + Sync + 'static, U: Clone + Send + Sync + 'static, { client.get_ref().get_user().to_string() } #[get("/const")] async fn with_const() -> String { format!("{N}") } fn main() { let app = App::new() .app_data(web::Data::new(UserClient)) .app_data(web::Data::new(Flag)) .service(index::::default()) .service(multi::::default()) .service(with_const::<3>::default()); let _ = app; }