Skip to content

Add Empty #37

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

Merged
merged 3 commits into from
Feb 23, 2021
Merged

Add Empty #37

merged 3 commits into from
Feb 23, 2021

Conversation

davidpdrsn
Copy link
Member

Empty is a little utility type that I have found useful in a few
scenarios. For example to make a "catch all" tower::Service that
always returns 404 Not Found with an empty body.

`Empty` is a little utility type that I have found useful in a few
scenarios. For example to make a "catch all" `tower::Service` that
always returns `404 Not Found` with an empty body.
Comment on lines +27 to +29
pub fn new() -> Self {
Self::default()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Structs of this kind are usually created by a freestanding function rather than an associated function (cf. std::future::pending and futures_util::stream::empty).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm open to that but its not my personal preference. I would like to hear what someone else thinks.

@tesaguri
Copy link
Contributor

tesaguri commented Feb 6, 2021

Possibly related: hyperium/hyper#2345.

@LucioFranco LucioFranco merged commit 8441ab4 into hyperium:master Feb 23, 2021
@davidpdrsn davidpdrsn deleted the empty branch February 23, 2021 16:23
BenxiangGe pushed a commit to BenxiangGe/http-body that referenced this pull request Jul 26, 2021
Co-authored-by: Daiki Mizukami <[email protected]>
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.

3 participants