feat(util/full): introduce Full::into_inner()#155
Merged
cratelyn merged 1 commit intohyperium:masterfrom Jul 28, 2025
Merged
Conversation
da8bb2a to
d12030b
Compare
fixes hyperium#154. this commit introduces a `http_body_util::Full::into_inner()` method. this allows callers to consume a `Full<D>`, and reacquire the wrapped value. this matches the style of [many interfaces][into-inner-docs] offered by various types provided in `core` and `std` such as `Box<T>`, `Arc<T>`, `Mutex<T>`, as well as [many interfaces][tokio-into-inner-docs] offered by various types in `tokio` such as `BufWriter<T>`, `OnceCell<T>`, and so forth. this pattern is also mirrored in other `http_body_util` types including `Either<L, R>`. ```rust use http_body_util::Full; const DATA: &[u8] = b"hello"; let full = Full::new(DATA); assert_eq!(full.into_inner(), Some("hello").map(str::as_bytes)); ``` NB: an `Full::inner()` method is not provided here. other types in `std` and `tokio` do not expose such a method. idiomatically, once a chunk is placed into a `Full<T>` it should be thought of as a `Body` rather than a `T`, and `inner()` would make this a leaky abstraction. [into-inner-docs]: https://doc.rust-lang.org/stable/std/?search=into_inner [tokio-into-inner-docs]: https://docs.rs/tokio/latest/tokio/?search=into_inner Signed-off-by: katelyn martin <git@katelyn.world>
d12030b to
ae38f8d
Compare
seanmonstar
approved these changes
Jul 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #154.
this commit introduces a
http_body_util::Full::into_inner()method.this allows callers to consume a
Full<D>, and reacquire the wrapped value. this matches the style of many interfaces offered by various types provided incoreandstdsuch asBox<T>,Arc<T>,Mutex<T>, as well as many interfaces offered by various types intokiosuch asBufWriter<T>,OnceCell<T>, and so forth.this pattern is also mirrored in other
http_body_utiltypes includingEither<L, R>.NB: an
Full::inner()method is not provided here. other types instdandtokiodo not expose such a method. idiomatically, once a chunk is placed into aFull<T>it should be thought of as aBodyrather than aT, andinner()would make this a leaky abstraction.