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

Add layer_fn #491

Merged
merged 6 commits into from Dec 29, 2020
Merged

Add layer_fn #491

merged 6 commits into from Dec 29, 2020

Conversation

davidpdrsn
Copy link
Member

Resolves #267

I went with layer_fn over layer::from_fn because changing service_fn would be a breaking change. But I don't mind changing it if you think thats more appropriate 😊

Copy link
Collaborator

@olix0r olix0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thanks ;)

Comment on lines 3 to 4
/// Returns a new `impl Layer` with the given closure.
pub fn layer_fn<F, S, T>(f: F) -> impl Layer<S, Service = T> + Clone
Copy link
Member

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?

Copy link
Member Author

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

tower-layer/src/layer_fn.rs Outdated Show resolved Hide resolved
Copy link
Member

@hawkw hawkw left a 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.

tower-layer/src/layer_fn.rs Outdated Show resolved Hide resolved
tower-layer/src/layer_fn.rs Show resolved Hide resolved
tower-layer/src/layer_fn.rs Outdated Show resolved Hide resolved
@hawkw hawkw merged commit f76fe9f into tower-rs:master Dec 29, 2020
@davidpdrsn davidpdrsn deleted the layer-fn branch December 29, 2020 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

util: add LayerFn which implements Layer for a closure
3 participants