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
Add layer_fn
#491
Add layer_fn
#491
Conversation
Fixes #267
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! thanks ;)
tower-layer/src/layer_fn.rs
Outdated
/// Returns a new `impl Layer` with the given closure. | ||
pub fn layer_fn<F, S, T>(f: F) -> impl Layer<S, Service = T> + Clone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could be nice to have an example here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ofc. Added one in bbf93a7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall — I had some docs suggestions.
Resolves #267
I went with
layer_fn
overlayer::from_fn
because changingservice_fn
would be a breaking change. But I don't mind changing it if you think thats more appropriate 😊