1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-20 08:31:09 +00:00

pass request ownership to closure instead of ref

This commit is contained in:
Nikolay Kim 2019-04-16 15:43:55 -07:00
parent 5740f1e63a
commit cc8420377e
2 changed files with 15 additions and 6 deletions

View file

@ -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

View file

@ -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.