Skip to content

Commit

Permalink
Apply clippy suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Feb 25, 2021
1 parent d8e45fc commit 35042e4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
10 changes: 2 additions & 8 deletions src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ impl DeltaCookie {
/// Create a new `DeltaCookie` that is being added to a jar.
#[inline]
pub fn added(cookie: Cookie<'static>) -> DeltaCookie {
DeltaCookie {
cookie: cookie,
removed: false,
}
DeltaCookie { cookie, removed: false, }
}

/// Create a new `DeltaCookie` that is being removed from a jar. The
/// `cookie` should be a "removal" cookie.
#[inline]
pub fn removed(cookie: Cookie<'static>) -> DeltaCookie {
DeltaCookie {
cookie: cookie,
removed: true,
}
DeltaCookie { cookie, removed: true, }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl CookieJar {
self.delta_cookies
.get(name)
.or_else(|| self.original_cookies.get(name))
.and_then(|c| if !c.removed { Some(&c.cookie) } else { None })
.and_then(|c| if c.removed { None } else { Some(&c.cookie) })
}

/// Adds an "original" `cookie` to this jar. If an original cookie with the
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl<'c> CookieStr<'c> {
}
}

#[allow(clippy::ptr_arg)]
fn to_raw_str<'s, 'b: 's>(&'s self, string: &'s Cow<'b, str>) -> Option<&'b str> {
match *self {
CookieStr::Indexed(i, j) => {
Expand Down
11 changes: 3 additions & 8 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ use crate::{Cookie, SameSite, CookieStr};

/// Enum corresponding to a parsing error.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[non_exhaustive]
pub enum ParseError {
/// The cookie did not contain a name/value pair.
MissingPair,
/// The cookie's name was empty.
EmptyName,
/// Decoding the cookie's name or value resulted in invalid UTF-8.
Utf8Error(Utf8Error),
/// It is discouraged to exhaustively match on this enum as its variants may
/// grow without a breaking-change bump in version numbers.
#[doc(hidden)]
__Nonexhasutive,
}

impl ParseError {
Expand All @@ -37,7 +34,6 @@ impl ParseError {
ParseError::Utf8Error(_) => {
"decoding the cookie's name or value resulted in invalid UTF-8"
}
ParseError::__Nonexhasutive => unreachable!("__Nonexhasutive ParseError"),
}
}
}
Expand Down Expand Up @@ -155,9 +151,8 @@ fn parse_inner<'c>(s: &str, decode: bool) -> Result<Cookie<'c>, ParseError> {
};

let mut cookie: Cookie<'c> = Cookie {
name, value,
cookie_string: None,
name: name,
value: value,
expires: None,
max_age: None,
domain: None,
Expand Down Expand Up @@ -193,7 +188,7 @@ fn parse_inner<'c>(s: &str, decode: bool) -> Result<Cookie<'c>, ParseError> {
} else {
Some(v.parse::<i64>()
.map(Duration::seconds)
.unwrap_or(Duration::seconds(i64::max_value())))
.unwrap_or_else(|_| Duration::seconds(i64::max_value())))
}
},
("domain", Some(mut domain)) if !domain.is_empty() => {
Expand Down
2 changes: 1 addition & 1 deletion src/secure/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ macro_rules! assert_secure_behaviour {
// Nikolai Vazquez. See https://github.com/nvzqz/static-assertions-rs for more.
macro_rules! const_assert {
($x:expr $(,)?) => {
#[allow(unknown_lints, eq_op)]
#[allow(unknown_lints, clippy::eq_op)]
const _: [(); 0 - !{ const ASSERT: bool = $x; ASSERT } as usize] = [];
};
}

0 comments on commit 35042e4

Please sign in to comment.