Skip to content

Commit 696d457

Browse files
committed
Update from Clippy lints
1 parent 59f6985 commit 696d457

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

examples/json.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//! isahc = { version = "*", features = ["json"]}
77
//! ```
88
9+
#![allow(dead_code)]
10+
911
use isahc::{prelude::*, Request};
1012

1113
#[derive(Debug, serde::Serialize)]

src/config/dial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl FromStr for Dialer {
134134
if s.starts_with("unix:") {
135135
// URI paths are always absolute.
136136
let mut path = std::path::PathBuf::from("/");
137-
path.push(&s[5..].trim_start_matches('/'));
137+
path.push(s[5..].trim_start_matches('/'));
138138

139139
return Ok(Self(Inner::UnixSocket(path)));
140140
}

src/cookies/jar.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{
1313
#[derive(Clone, Debug)]
1414
pub struct CookieRejectedError {
1515
kind: CookieRejectedErrorKind,
16-
cookie: Cookie,
16+
cookie: Box<Cookie>,
1717
}
1818

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

3737
impl CookieRejectedError {
38+
fn new(kind: CookieRejectedErrorKind, cookie: Cookie) -> Self {
39+
Self {
40+
kind,
41+
cookie: Box::new(cookie),
42+
}
43+
}
44+
3845
/// Get the kind of error that occurred.
3946
pub fn kind(&self) -> CookieRejectedErrorKind {
4047
self.kind
4148
}
4249

4350
/// Get back the [`Cookie`] that failed to be set.
4451
pub fn cookie(self) -> Cookie {
45-
self.cookie
52+
*self.cookie
4653
}
4754
}
4855

@@ -138,10 +145,10 @@ impl CookieJar {
138145
"cookie '{}' dropped, no domain specified in request URI",
139146
cookie.name()
140147
);
141-
return Err(CookieRejectedError {
142-
kind: CookieRejectedErrorKind::InvalidRequestDomain,
148+
return Err(CookieRejectedError::new(
149+
CookieRejectedErrorKind::InvalidRequestDomain,
143150
cookie,
144-
});
151+
));
145152
};
146153

147154
// Perform some validations on the domain.
@@ -155,10 +162,10 @@ impl CookieJar {
155162
request_host,
156163
domain
157164
);
158-
return Err(CookieRejectedError {
159-
kind: CookieRejectedErrorKind::DomainMismatch,
165+
return Err(CookieRejectedError::new(
166+
CookieRejectedErrorKind::DomainMismatch,
160167
cookie,
161-
});
168+
));
162169
}
163170

164171
// Drop cookies for top-level domains.
@@ -168,10 +175,10 @@ impl CookieJar {
168175
cookie.name(),
169176
domain
170177
);
171-
return Err(CookieRejectedError {
172-
kind: CookieRejectedErrorKind::InvalidCookieDomain,
178+
return Err(CookieRejectedError::new(
179+
CookieRejectedErrorKind::InvalidCookieDomain,
173180
cookie,
174-
});
181+
));
175182
}
176183

177184
// Check the PSL for bad domain suffixes if available.
@@ -184,10 +191,10 @@ impl CookieJar {
184191
cookie.name(),
185192
domain
186193
);
187-
return Err(CookieRejectedError {
188-
kind: CookieRejectedErrorKind::InvalidCookieDomain,
194+
return Err(CookieRejectedError::new(
195+
CookieRejectedErrorKind::InvalidCookieDomain,
189196
cookie,
190-
});
197+
));
191198
}
192199
}
193200
}

src/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl RequestHandler {
167167
let mut easy = Easy2::new(handler);
168168
easy.get_mut().handle = easy.raw();
169169
let id = easy.get_ref().id();
170-
easy.get_mut().span.record("id", &id);
170+
easy.get_mut().span.record("id", id);
171171

172172
(easy, future)
173173
}

0 commit comments

Comments
 (0)