mirror of https://github.com/fafhrd91/actix-web
Refactor: Use mut-ref to insert instead move of cookies value
This commit is contained in:
parent
8bd8ee7b18
commit
5eb4ee27e8
16
src/test.rs
16
src/test.rs
|
@ -550,21 +550,19 @@ impl<S: 'static> TestRequest<S> {
|
||||||
/// set cookie of this request
|
/// set cookie of this request
|
||||||
pub fn cookie(mut self, cookie: Cookie<'static>) -> Self {
|
pub fn cookie(mut self, cookie: Cookie<'static>) -> Self {
|
||||||
let mut should_insert = true;
|
let mut should_insert = true;
|
||||||
let mut cookies = match self.cookies {
|
match &mut self.cookies {
|
||||||
Some(old_cookies) => {
|
Some(old_cookies) => {
|
||||||
for old_cookie in &old_cookies {
|
for old_cookie in old_cookies.iter() {
|
||||||
if old_cookie == &cookie {
|
if old_cookie == &cookie {
|
||||||
should_insert = false
|
should_insert = false
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
old_cookies
|
if should_insert {
|
||||||
|
old_cookies.push(cookie);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
None => { Vec::<Cookie>::new() }
|
None => {}
|
||||||
};
|
};
|
||||||
if should_insert {
|
|
||||||
cookies.push(cookie)
|
|
||||||
};
|
|
||||||
self.cookies = Some(cookies);
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue