Skip to content

Commit

Permalink
Make RequestParts::body_mut return &mut Option<B>
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn committed Mar 18, 2022
1 parent 422a883 commit b9da0cc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions axum-core/src/extract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ impl<B> RequestParts<B> {
/// Gets a mutable reference to the request body.
///
/// Returns `None` if the body has been taken by another extractor.
pub fn body_mut(&mut self) -> Option<&mut B> {
self.body.as_mut()
// this returns `&mut Option<B>` rather than `Option<&mut B>` such that users can swap it
pub fn body_mut(&mut self) -> &mut Option<B> {
&mut self.body
}

/// Takes the body out of the request, leaving a `None` in its place.
Expand Down

0 comments on commit b9da0cc

Please sign in to comment.