diff --git a/actix-redis/src/session.rs b/actix-redis/src/session.rs index 80320f4ad..741e31a4a 100644 --- a/actix-redis/src/session.rs +++ b/actix-redis/src/session.rs @@ -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 diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index 7c8011c21..fc94324bd 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -1,6 +1,7 @@ # Changes ## Unreleased - 2020-xx-xx +* `Session::set_session` takes a `IntoIterator` instead of `Iterator` ## 0.4.0 - 2020-09-11 diff --git a/actix-session/src/cookie.rs b/actix-session/src/cookie.rs index 32dac0da5..135f8e5f2 100644 --- a/actix-session/src/cookie.rs +++ b/actix-session/src/cookie.rs @@ -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); diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index 02dd1a838..c323342f2 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -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, + data: impl IntoIterator, req: &mut ServiceRequest, ) { let session = Session::get_session(&mut *req.extensions_mut()); @@ -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()); @@ -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, ); @@ -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, );