How do I find implementor that fit into/satisfy a trait?

Let's look at this documentation, taken from actix-web docs.

As we see on the docs, when we call HttpServer::new(factory: F) function, it takes an argument with generic type F, where F was explained in where clause. When I read what is F, it's very confusing since F was related to many traits.

Fortunately, the docs gives an example, so I know what should be injected to F which is closure that return a call from App::new().service(web::resource("/").to(|| HttpResponse::Ok())). That can be done because it's satisfy F.
But what if I want to explore possibilities that I can inject into F? How do I know what else that satisfy F just from read the API docs? I feel that this is really difficult.

Note that this problem can be applied to any docs, not just actix-web. Actix-web is just an example for what I'm facing currently.

For a specific trait, you can open the trait's doc and scroll down. There's a list of types that implement it.

Yes, but are there a way to get list of types that satisfy all of this?:
so I can find quickly what can be injected to F.
If there are no way to do that, so how you usually do to find what can be injected into F?

In general, this is a useful tip. In this particular case, the generated docs are unfortunately terribly intransparent. You cannot even find out that App implements IntoServiceFactory without looking into the source, and looking at that trait’s page of course doesn’t help either since it’s in a different crate.

1 Like

When the docs have ridiculous constraints like that, there's not much you can do, and you just have to hope that the documentation they wrote explains it.

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.