Skip to content

Suggestion: Dealing with ServiceProvider instance type with .boxed() #16

@leonardoarcari

Description

@leonardoarcari

Hey! I've been experimenting with teloc for a while now as I'm surveing crates enabling Hexagonal Architecture in Rust.

In the context of leveraging IoC pattern that teloc implements, I faced the inefficiency of having to modify over and over the type alias for ServiceProvider instance.

This is an issue affecting every crate exploiting Rust generics support, but I came across an interesting pattern that the axum fellows implemented to deal with it.

In axum, HTTP routes are implemented composing generic type, leading to big types that only the compiler will eventually know. To make building routes developer-friendly, they provide a .boxed() method returning a BoxRoute that erases the big generic type.

References are available here:

Do you think this might be implementable in teloc as well? It would make declaring containers much more ergonomic, imho.

Anyhow, keep up the good work! 💪

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions