mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 00:21:08 +01:00
pass request ownership to closure instead of ref
This commit is contained in:
parent
5740f1e63a
commit
cc8420377e
@ -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 New Issue
Block a user