Skip to content

Commit 4ea0be0

Browse files
committed
refactor(clippy): reduce clippy warnings
1 parent 12717d1 commit 4ea0be0

File tree

24 files changed

+113
-124
lines changed

24 files changed

+113
-124
lines changed

benches/end_to_end.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn http1_parallel_x10_req_10kb_100_chunks(b: &mut test::Bencher) {
8282
#[bench]
8383
#[ignore]
8484
fn http1_parallel_x10_res_1mb(b: &mut test::Bencher) {
85-
let body = &[b'x'; 1024 * 1024 * 1];
85+
let body = &[b'x'; 1024 * 1024];
8686
opts().parallel(10).response_body(body).bench(b)
8787
}
8888

@@ -177,7 +177,7 @@ fn http2_parallel_x10_req_10kb_100_chunks_max_window(b: &mut test::Bencher) {
177177

178178
#[bench]
179179
fn http2_parallel_x10_res_1mb(b: &mut test::Bencher) {
180-
let body = &[b'x'; 1024 * 1024 * 1];
180+
let body = &[b'x'; 1024 * 1024];
181181
opts()
182182
.http2()
183183
.parallel(10)

benches/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn raw_tcp_throughput_small_payload(b: &mut test::Bencher) {
152152

153153
let mut buf = [0u8; 8192];
154154
while rx.try_recv().is_err() {
155-
sock.read(&mut buf).unwrap();
155+
sock.read_exact(&mut buf).unwrap();
156156
sock.write_all(
157157
b"\
158158
HTTP/1.1 200 OK\r\n\

benches/support/tokiort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Timer for TokioTimer {
4444

4545
fn reset(&self, sleep: &mut Pin<Box<dyn Sleep>>, new_deadline: Instant) {
4646
if let Some(sleep) = sleep.as_mut().downcast_mut_pin::<TokioSleep>() {
47-
sleep.reset(new_deadline.into())
47+
sleep.reset(new_deadline)
4848
}
4949
}
5050
}

examples/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async fn fetch_url(url: hyper::Uri) -> Result<()> {
7171
while let Some(next) = res.frame().await {
7272
let frame = next?;
7373
if let Some(chunk) = frame.data_ref() {
74-
io::stdout().write_all(&chunk).await?;
74+
io::stdout().write_all(chunk).await?;
7575
}
7676
}
7777

examples/gateway.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1515
let in_addr: SocketAddr = ([127, 0, 0, 1], 3001).into();
1616
let out_addr: SocketAddr = ([127, 0, 0, 1], 3000).into();
1717

18-
let out_addr_clone = out_addr.clone();
18+
let out_addr_clone = out_addr;
1919

2020
let listener = TcpListener::bind(in_addr).await?;
2121

examples/http_proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async fn proxy(
111111
}
112112

113113
fn host_addr(uri: &http::Uri) -> Option<String> {
114-
uri.authority().and_then(|auth| Some(auth.to_string()))
114+
uri.authority().map(|auth| auth.to_string())
115115
}
116116

117117
fn empty() -> BoxBody<Bytes, hyper::Error> {

examples/single_threaded.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ async fn http1_client(url: hyper::Uri) -> Result<(), Box<dyn std::error::Error>>
207207
while let Some(next) = res.frame().await {
208208
let frame = next?;
209209
if let Some(chunk) = frame.data_ref() {
210-
stdout.write_all(&chunk).await.unwrap();
210+
stdout.write_all(chunk).await.unwrap();
211211
}
212212
}
213213
stdout.write_all(b"\n-----------------\n").await.unwrap();
@@ -308,7 +308,7 @@ async fn http2_client(url: hyper::Uri) -> Result<(), Box<dyn std::error::Error>>
308308
while let Some(next) = res.frame().await {
309309
let frame = next?;
310310
if let Some(chunk) = frame.data_ref() {
311-
stdout.write_all(&chunk).await.unwrap();
311+
stdout.write_all(chunk).await.unwrap();
312312
}
313313
}
314314
stdout.write_all(b"\n-----------------\n").await.unwrap();

examples/upgrades.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ async fn main() {
169169
res = &mut conn => {
170170
if let Err(err) = res {
171171
println!("Error serving connection: {:?}", err);
172-
return;
173172
}
174173
}
175174
// Continue polling the connection after enabling graceful shutdown.
@@ -187,7 +186,7 @@ async fn main() {
187186
});
188187

189188
// Client requests a HTTP connection upgrade.
190-
let request = client_upgrade_request(addr.clone());
189+
let request = client_upgrade_request(addr);
191190
if let Err(e) = request.await {
192191
eprintln!("client error: {}", e);
193192
}

examples/web_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async fn main() -> Result<()> {
117117
let io = TokioIo::new(stream);
118118

119119
tokio::task::spawn(async move {
120-
let service = service_fn(move |req| response_examples(req));
120+
let service = service_fn(response_examples);
121121

122122
if let Err(err) = http1::Builder::new().serve_connection(io, service).await {
123123
println!("Failed to serve connection: {:?}", err);

src/client/conn/http1.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ where
302302

303303
// ===== impl Builder
304304

305+
impl Default for Builder {
306+
fn default() -> Builder {
307+
Builder::new()
308+
}
309+
}
310+
305311
impl Builder {
306312
/// Creates a new connection builder.
307313
#[inline]

0 commit comments

Comments
 (0)