Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile time issues with Router::boxed #385

Closed
wants to merge 3 commits into from

Conversation

davidpdrsn
Copy link
Member

This adds BoxRouterLayer (created with BoxRouter::layer) which is used to box routes and removes Router::boxed. Rust is apparently bad a checking trait bounds on functions (such as Router::boxed) but deals just fine with trait bounds in impls 🤷

Curiously doing .layer(BoxRouter::layer()) is slow, but .layer(BoxRoute::<Body>::layer()) is fast even though BoxRouter's first generic parameter defaults to Body 🤔 So the docs specifically call out using .layer(BoxRoute::<Body>::layer()). I've tried making it required at compile time to always use a turbofish but haven't found a way.

I still wanna do a bit more testing hence the draft. If things turn out to work well I think we should consider backporting this to 0.2 but deprecating Router::boxed instead of removing it.

@davidpdrsn davidpdrsn added the C-enhancement Category: A PR with an enhancement label Oct 14, 2021
@davidpdrsn davidpdrsn added this to the 0.3 milestone Oct 14, 2021
@davidpdrsn davidpdrsn modified the milestones: 0.3, 0.4 Oct 24, 2021
@davidpdrsn
Copy link
Member Author

Superseded by #401

@davidpdrsn davidpdrsn closed this Oct 24, 2021
@davidpdrsn davidpdrsn deleted the fix-boxed-compile-time-issues branch October 24, 2021 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: A PR with an enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant