Skip to content

Commit

Permalink
Update from Clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Nov 7, 2022
1 parent 59f6985 commit 696d457
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
2 changes: 2 additions & 0 deletions examples/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//! isahc = { version = "*", features = ["json"]}
//! ```
#![allow(dead_code)]

use isahc::{prelude::*, Request};

#[derive(Debug, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/config/dial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl FromStr for Dialer {
if s.starts_with("unix:") {
// URI paths are always absolute.
let mut path = std::path::PathBuf::from("/");
path.push(&s[5..].trim_start_matches('/'));
path.push(s[5..].trim_start_matches('/'));

return Ok(Self(Inner::UnixSocket(path)));
}
Expand Down
35 changes: 21 additions & 14 deletions src/cookies/jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
#[derive(Clone, Debug)]
pub struct CookieRejectedError {
kind: CookieRejectedErrorKind,
cookie: Cookie,
cookie: Box<Cookie>,
}

/// The reason why the [`Cookie`] was rejected.
Expand All @@ -35,14 +35,21 @@ pub enum CookieRejectedErrorKind {
}

impl CookieRejectedError {
fn new(kind: CookieRejectedErrorKind, cookie: Cookie) -> Self {
Self {
kind,
cookie: Box::new(cookie),
}
}

/// Get the kind of error that occurred.
pub fn kind(&self) -> CookieRejectedErrorKind {
self.kind
}

/// Get back the [`Cookie`] that failed to be set.
pub fn cookie(self) -> Cookie {
self.cookie
*self.cookie
}
}

Expand Down Expand Up @@ -138,10 +145,10 @@ impl CookieJar {
"cookie '{}' dropped, no domain specified in request URI",
cookie.name()
);
return Err(CookieRejectedError {
kind: CookieRejectedErrorKind::InvalidRequestDomain,
return Err(CookieRejectedError::new(
CookieRejectedErrorKind::InvalidRequestDomain,
cookie,
});
));
};

// Perform some validations on the domain.
Expand All @@ -155,10 +162,10 @@ impl CookieJar {
request_host,
domain
);
return Err(CookieRejectedError {
kind: CookieRejectedErrorKind::DomainMismatch,
return Err(CookieRejectedError::new(
CookieRejectedErrorKind::DomainMismatch,
cookie,
});
));
}

// Drop cookies for top-level domains.
Expand All @@ -168,10 +175,10 @@ impl CookieJar {
cookie.name(),
domain
);
return Err(CookieRejectedError {
kind: CookieRejectedErrorKind::InvalidCookieDomain,
return Err(CookieRejectedError::new(
CookieRejectedErrorKind::InvalidCookieDomain,
cookie,
});
));
}

// Check the PSL for bad domain suffixes if available.
Expand All @@ -184,10 +191,10 @@ impl CookieJar {
cookie.name(),
domain
);
return Err(CookieRejectedError {
kind: CookieRejectedErrorKind::InvalidCookieDomain,
return Err(CookieRejectedError::new(
CookieRejectedErrorKind::InvalidCookieDomain,
cookie,
});
));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl RequestHandler {
let mut easy = Easy2::new(handler);
easy.get_mut().handle = easy.raw();
let id = easy.get_ref().id();
easy.get_mut().span.record("id", &id);
easy.get_mut().span.record("id", id);

(easy, future)
}
Expand Down

0 comments on commit 696d457

Please sign in to comment.