mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
Make RequestParts::body_mut return &mut Option<B> (#869)
This commit is contained in:
@@ -37,11 +37,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- `<Request as FromRequest>::Rejection` is now `BodyAlreadyExtracted`.
|
- `<Request as FromRequest>::Rejection` is now `BodyAlreadyExtracted`.
|
||||||
- `<http::request::Parts as FromRequest>::Rejection` is now `Infallible`.
|
- `<http::request::Parts as FromRequest>::Rejection` is now `Infallible`.
|
||||||
- `ExtensionsAlreadyExtracted` has been removed.
|
- `ExtensionsAlreadyExtracted` has been removed.
|
||||||
|
- **breaking:** `RequestParts::body_mut` now returns `&mut Option<B>` so the
|
||||||
|
body can be swapped ([#869])
|
||||||
|
|
||||||
[#698]: https://github.com/tokio-rs/axum/pull/698
|
[#698]: https://github.com/tokio-rs/axum/pull/698
|
||||||
[#699]: https://github.com/tokio-rs/axum/pull/699
|
[#699]: https://github.com/tokio-rs/axum/pull/699
|
||||||
[#767]: https://github.com/tokio-rs/axum/pull/767
|
[#767]: https://github.com/tokio-rs/axum/pull/767
|
||||||
[#797]: https://github.com/tokio-rs/axum/pull/797
|
[#797]: https://github.com/tokio-rs/axum/pull/797
|
||||||
|
[#869]: https://github.com/tokio-rs/axum/pull/869
|
||||||
|
|
||||||
# 0.1.1 (06. December, 2021)
|
# 0.1.1 (06. December, 2021)
|
||||||
|
|
||||||
|
|||||||
@@ -204,8 +204,9 @@ impl<B> RequestParts<B> {
|
|||||||
/// Gets a mutable reference to the request body.
|
/// Gets a mutable reference to the request body.
|
||||||
///
|
///
|
||||||
/// Returns `None` if the body has been taken by another extractor.
|
/// Returns `None` if the body has been taken by another extractor.
|
||||||
pub fn body_mut(&mut self) -> Option<&mut B> {
|
// this returns `&mut Option<B>` rather than `Option<&mut B>` such that users can use it to set the body.
|
||||||
self.body.as_mut()
|
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.
|
/// Takes the body out of the request, leaving a `None` in its place.
|
||||||
|
|||||||
Reference in New Issue
Block a user