Skip to content

Commit

Permalink
Update Session::set_session to take IntoIterator (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
FallenWarrior2k authored Sep 21, 2020
1 parent 03ccf09 commit bb8120a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion actix-redis/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ where
Box::pin(async move {
let state = inner.load(&req).await?;
let value = if let Some((state, value)) = state {
Session::set_session(state.into_iter(), &mut req);
Session::set_session(state, &mut req);
Some(value)
} else {
None
Expand Down
1 change: 1 addition & 0 deletions actix-session/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changes

## Unreleased - 2020-xx-xx
* `Session::set_session` takes a `IntoIterator` instead of `Iterator`


## 0.4.0 - 2020-09-11
Expand Down
2 changes: 1 addition & 1 deletion actix-session/src/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ where
let inner = self.inner.clone();
let (is_new, state) = self.inner.load(&req);
let prolong_expiration = self.inner.expires_in.is_some();
Session::set_session(state.into_iter(), &mut req);
Session::set_session(state, &mut req);

let fut = self.service.call(req);

Expand Down
11 changes: 5 additions & 6 deletions actix-session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ impl Session {
/// let mut req = test::TestRequest::default().to_srv_request();
///
/// Session::set_session(
/// vec![("counter".to_string(), serde_json::to_string(&0).unwrap())].into_iter(),
/// vec![("counter".to_string(), serde_json::to_string(&0).unwrap())],
/// &mut req,
/// );
/// ```
pub fn set_session(
data: impl Iterator<Item = (String, String)>,
data: impl IntoIterator<Item = (String, String)>,
req: &mut ServiceRequest,
) {
let session = Session::get_session(&mut *req.extensions_mut());
Expand Down Expand Up @@ -279,8 +279,7 @@ mod tests {
let mut req = test::TestRequest::default().to_srv_request();

Session::set_session(
vec![("key".to_string(), serde_json::to_string("value").unwrap())]
.into_iter(),
vec![("key".to_string(), serde_json::to_string("value").unwrap())],
&mut req,
);
let session = Session::get_session(&mut *req.extensions_mut());
Expand All @@ -301,7 +300,7 @@ mod tests {
let mut req = test::TestRequest::default().to_srv_request();

Session::set_session(
vec![("key".to_string(), serde_json::to_string(&true).unwrap())].into_iter(),
vec![("key".to_string(), serde_json::to_string(&true).unwrap())],
&mut req,
);

Expand All @@ -315,7 +314,7 @@ mod tests {
let mut req = test::TestRequest::default().to_srv_request();

Session::set_session(
vec![("key".to_string(), serde_json::to_string(&10).unwrap())].into_iter(),
vec![("key".to_string(), serde_json::to_string(&10).unwrap())],
&mut req,
);

Expand Down

0 comments on commit bb8120a

Please sign in to comment.