Skip to content

Commit

Permalink
Implement Clone for CookieJar, PrivateCookieJar and `SignedCook…
Browse files Browse the repository at this point in the history
…ieJar` (#1808)
  • Loading branch information
danhandrea authored Mar 3, 2023
1 parent aa2cbf6 commit e167cfc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions axum-extra/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning].
except that it enforces field exclusivity at runtime instead of compile time,
as this improves usability.

- **added:** Implement `Clone` for `CookieJar`, `PrivateCookieJar` and `SignedCookieJar` ([#1808])

[#1808]: https://github.com/tokio-rs/axum/pull/1808

# 0.6.0 (24. February, 2022)

- **breaking:** Change casing of `ProtoBuf` to `Protobuf` ([#1595])
Expand Down
2 changes: 1 addition & 1 deletion axum-extra/src/extract/cookie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub use cookie::Key;
/// .route("/me", get(me));
/// # let app: Router = app;
/// ```
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone)]
pub struct CookieJar {
jar: cookie::CookieJar,
}
Expand Down
10 changes: 10 additions & 0 deletions axum-extra/src/extract/cookie/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,13 @@ impl<'a, K> Iterator for PrivateCookieJarIter<'a, K> {
}
}
}

impl<K> Clone for PrivateCookieJar<K> {
fn clone(&self) -> Self {
Self {
jar: self.jar.clone(),
key: self.key.clone(),
_marker: self._marker,
}
}
}
10 changes: 10 additions & 0 deletions axum-extra/src/extract/cookie/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,13 @@ impl<'a, K> Iterator for SignedCookieJarIter<'a, K> {
}
}
}

impl<K> Clone for SignedCookieJar<K> {
fn clone(&self) -> Self {
Self {
jar: self.jar.clone(),
key: self.key.clone(),
_marker: self._marker,
}
}
}

0 comments on commit e167cfc

Please sign in to comment.