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

feat(util): add const constructor for empty Full #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tottoto
Copy link
Contributor

@tottoto tottoto commented Aug 6, 2024

Adds const constructor for empty Full.

@@ -18,6 +18,11 @@ impl<D> Full<D>
where
D: Buf,
{
/// Create a new empty `Full`.
pub const fn empty() -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

This is what the Empty type is for, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If client use the Empty type for the case to describe empty body where the functionality provided by Full is sufficient and do not need to prepare the own Body type, client will need to either box it and erase the type or define the own wrapping type, since Empty is a different type from Full. Being able to use an empty Full type in a const context is useful, as it allows client to define fixed responses that are often used for fallbacks.

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.

2 participants