mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 22:49:21 +02:00
update tests and clippy warnings
This commit is contained in:
@ -18,7 +18,6 @@ use super::{Cookie, SameSite};
|
||||
/// ```rust
|
||||
/// use actix_http::cookie::Cookie;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let cookie: Cookie = Cookie::build("name", "value")
|
||||
/// .domain("www.rust-lang.org")
|
||||
/// .path("/")
|
||||
@ -26,7 +25,6 @@ use super::{Cookie, SameSite};
|
||||
/// .http_only(true)
|
||||
/// .max_age(84600)
|
||||
/// .finish();
|
||||
/// # }
|
||||
/// ```
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CookieBuilder {
|
||||
@ -65,13 +63,11 @@ impl CookieBuilder {
|
||||
/// ```rust
|
||||
/// use actix_http::cookie::Cookie;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let c = Cookie::build("foo", "bar")
|
||||
/// .expires(time::now())
|
||||
/// .finish();
|
||||
///
|
||||
/// assert!(c.expires().is_some());
|
||||
/// # }
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn expires(mut self, when: Tm) -> CookieBuilder {
|
||||
@ -86,13 +82,11 @@ impl CookieBuilder {
|
||||
/// ```rust
|
||||
/// use actix_http::cookie::Cookie;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let c = Cookie::build("foo", "bar")
|
||||
/// .max_age(1800)
|
||||
/// .finish();
|
||||
///
|
||||
/// assert_eq!(c.max_age(), Some(time::Duration::seconds(30 * 60)));
|
||||
/// # }
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn max_age(self, seconds: i64) -> CookieBuilder {
|
||||
@ -106,13 +100,11 @@ impl CookieBuilder {
|
||||
/// ```rust
|
||||
/// use actix_http::cookie::Cookie;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let c = Cookie::build("foo", "bar")
|
||||
/// .max_age_time(time::Duration::minutes(30))
|
||||
/// .finish();
|
||||
///
|
||||
/// assert_eq!(c.max_age(), Some(time::Duration::seconds(30 * 60)));
|
||||
/// # }
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn max_age_time(mut self, value: Duration) -> CookieBuilder {
|
||||
@ -222,14 +214,12 @@ impl CookieBuilder {
|
||||
/// use actix_http::cookie::Cookie;
|
||||
/// use chrono::Duration;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let c = Cookie::build("foo", "bar")
|
||||
/// .permanent()
|
||||
/// .finish();
|
||||
///
|
||||
/// assert_eq!(c.max_age(), Some(Duration::days(365 * 20)));
|
||||
/// # assert!(c.expires().is_some());
|
||||
/// # }
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn permanent(mut self) -> CookieBuilder {
|
||||
|
@ -190,7 +190,6 @@ impl CookieJar {
|
||||
/// use actix_http::cookie::{CookieJar, Cookie};
|
||||
/// use chrono::Duration;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let mut jar = CookieJar::new();
|
||||
///
|
||||
/// // Assume this cookie originally had a path of "/" and domain of "a.b".
|
||||
@ -204,7 +203,6 @@ impl CookieJar {
|
||||
/// assert_eq!(delta.len(), 1);
|
||||
/// assert_eq!(delta[0].name(), "name");
|
||||
/// assert_eq!(delta[0].max_age(), Some(Duration::seconds(0)));
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// Removing a new cookie does not result in a _removal_ cookie:
|
||||
@ -243,7 +241,6 @@ impl CookieJar {
|
||||
/// use actix_http::cookie::{CookieJar, Cookie};
|
||||
/// use chrono::Duration;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let mut jar = CookieJar::new();
|
||||
///
|
||||
/// // Add an original cookie and a new cookie.
|
||||
@ -261,7 +258,6 @@ impl CookieJar {
|
||||
/// jar.force_remove(Cookie::new("key", "value"));
|
||||
/// assert_eq!(jar.delta().count(), 0);
|
||||
/// assert_eq!(jar.iter().count(), 0);
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn force_remove<'a>(&mut self, cookie: Cookie<'a>) {
|
||||
self.original_cookies.remove(cookie.name());
|
||||
|
@ -647,13 +647,11 @@ impl<'c> Cookie<'c> {
|
||||
/// use actix_http::cookie::Cookie;
|
||||
/// use chrono::Duration;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let mut c = Cookie::new("name", "value");
|
||||
/// assert_eq!(c.max_age(), None);
|
||||
///
|
||||
/// c.set_max_age(Duration::hours(10));
|
||||
/// assert_eq!(c.max_age(), Some(Duration::hours(10)));
|
||||
/// # }
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn set_max_age(&mut self, value: Duration) {
|
||||
@ -701,7 +699,6 @@ impl<'c> Cookie<'c> {
|
||||
/// ```rust
|
||||
/// use actix_http::cookie::Cookie;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let mut c = Cookie::new("name", "value");
|
||||
/// assert_eq!(c.expires(), None);
|
||||
///
|
||||
@ -710,7 +707,6 @@ impl<'c> Cookie<'c> {
|
||||
///
|
||||
/// c.set_expires(now);
|
||||
/// assert!(c.expires().is_some())
|
||||
/// # }
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn set_expires(&mut self, time: Tm) {
|
||||
@ -726,7 +722,6 @@ impl<'c> Cookie<'c> {
|
||||
/// use actix_http::cookie::Cookie;
|
||||
/// use chrono::Duration;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let mut c = Cookie::new("foo", "bar");
|
||||
/// assert!(c.expires().is_none());
|
||||
/// assert!(c.max_age().is_none());
|
||||
@ -734,7 +729,6 @@ impl<'c> Cookie<'c> {
|
||||
/// c.make_permanent();
|
||||
/// assert!(c.expires().is_some());
|
||||
/// assert_eq!(c.max_age(), Some(Duration::days(365 * 20)));
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn make_permanent(&mut self) {
|
||||
let twenty_years = Duration::days(365 * 20);
|
||||
|
Reference in New Issue
Block a user