mirror of
https://github.com/actix/actix-web.git
synced 2024-11-20 16:41:05 +00:00
pass request ownership to closure instead of ref
This commit is contained in:
parent
5740f1e63a
commit
cc8420377e
2 changed files with 15 additions and 6 deletions
|
@ -1,5 +1,12 @@
|
|||
# Changes
|
||||
|
||||
## [0.1.1] - 2019-04-xx
|
||||
|
||||
### Changed
|
||||
|
||||
* `ClientRequest::if_true()` and `ClientRequest::if_some()` use instance instead of ref
|
||||
|
||||
|
||||
## [0.1.0] - 2019-04-16
|
||||
|
||||
* No changes
|
||||
|
|
|
@ -333,24 +333,26 @@ impl ClientRequest {
|
|||
/// value is `true`.
|
||||
pub fn if_true<F>(mut self, value: bool, f: F) -> Self
|
||||
where
|
||||
F: FnOnce(&mut ClientRequest),
|
||||
F: FnOnce(ClientRequest) -> ClientRequest,
|
||||
{
|
||||
if value {
|
||||
f(&mut self);
|
||||
f(self)
|
||||
} else {
|
||||
self
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// This method calls provided closure with builder reference if
|
||||
/// value is `Some`.
|
||||
pub fn if_some<T, F>(mut self, value: Option<T>, f: F) -> Self
|
||||
where
|
||||
F: FnOnce(T, &mut ClientRequest),
|
||||
F: FnOnce(T, ClientRequest) -> ClientRequest,
|
||||
{
|
||||
if let Some(val) = value {
|
||||
f(val, &mut self);
|
||||
f(val, self)
|
||||
} else {
|
||||
self
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Complete request construction and send body.
|
||||
|
|
Loading…
Reference in a new issue