Skip to content

Commit 28f42e1

Browse files
authored
Merge pull request fussybeaver#213 from edmorley/fix-clippy-tests
Fix Clippy warnings in examples and tests
2 parents 757b07f + 96cf216 commit 28f42e1

File tree

17 files changed

+53
-59
lines changed

17 files changed

+53
-59
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- checkout
4646
- setup_remote_docker
4747
- run: docker build -t bollard .
48-
- run: docker run -ti --rm bollard bash -c "rustup component add clippy && cargo clippy -- -Dwarnings -Aclippy::upper_case_acronyms"
48+
- run: docker run -ti --rm bollard bash -c "rustup component add clippy && cargo clippy --all-targets -- -Dwarnings -Aclippy::upper_case_acronyms"
4949
test_audit:
5050
docker:
5151
- image: docker:20.10.11

examples/attach_container.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use tokio::io::AsyncWriteExt;
1818
use tokio::task::spawn;
1919
use tokio::time::sleep;
2020

21-
const IMAGE: &'static str = "alpine:3";
21+
const IMAGE: &str = "alpine:3";
2222

2323
#[tokio::main]
2424
async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
@@ -88,7 +88,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
8888

8989
// pipe docker attach output into stdout
9090
while let Some(Ok(output)) = output.next().await {
91-
stdout.write(output.into_bytes().as_ref())?;
91+
stdout.write_all(output.into_bytes().as_ref())?;
9292
stdout.flush()?;
9393
}
9494
}

examples/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
1313

1414
fn main() {
1515
run().unwrap();
16-
17-
()
1816
}

examples/exec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bollard::image::CreateImageOptions;
88
use futures_util::stream::StreamExt;
99
use futures_util::TryStreamExt;
1010

11-
const IMAGE: &'static str = "alpine:3";
11+
const IMAGE: &str = "alpine:3";
1212

1313
#[tokio::main]
1414
async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {

examples/exec_term.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use tokio::io::AsyncWriteExt;
1717
use tokio::task::spawn;
1818
use tokio::time::sleep;
1919

20-
const IMAGE: &'static str = "alpine:3";
20+
const IMAGE: &str = "alpine:3";
2121

2222
#[tokio::main]
2323
async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
@@ -98,7 +98,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
9898

9999
// pipe docker exec output into stdout
100100
while let Some(Ok(output)) = output.next().await {
101-
stdout.write(output.into_bytes().as_ref())?;
101+
stdout.write_all(output.into_bytes().as_ref())?;
102102
stdout.flush()?;
103103
}
104104
}

examples/info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::default::Default;
1010
use futures_util::stream;
1111
use futures_util::stream::StreamExt;
1212

13-
async fn conc(arg: (Docker, &ContainerSummary)) -> () {
13+
async fn conc(arg: (Docker, &ContainerSummary)) {
1414
let (docker, container) = arg;
1515
println!(
1616
"{:?}",

examples/kafka.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use futures_util::stream::select;
99
use futures_util::stream::StreamExt;
1010
use futures_util::stream::TryStreamExt;
1111

12-
const KAFKA_IMAGE: &'static str = "confluentinc/cp-kafka:5.0.1";
13-
const ZOOKEEPER_IMAGE: &'static str = "confluentinc/cp-zookeeper:5.0.1";
12+
const KAFKA_IMAGE: &str = "confluentinc/cp-kafka:5.0.1";
13+
const ZOOKEEPER_IMAGE: &str = "confluentinc/cp-zookeeper:5.0.1";
1414

1515
#[tokio::main]
1616
async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {

examples/top.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
4848
{
4949
if let Some(p) = p.get(0) {
5050
print!("{}", name);
51-
for mut v in p.to_vec() {
51+
for mut v in p.iter().cloned() {
5252
if v.len() > 30 {
5353
v.truncate(30);
5454
}
5555
print!("\t{}", v);
5656
}
57-
print!("\n");
57+
println!();
5858
}
5959
}
6060

src/docker.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ impl Docker {
403403

404404
let mut root_store = rustls::RootCertStore::empty();
405405
for cert in rustls_native_certs::load_native_certs()? {
406-
root_store.add(&rustls::Certificate(cert.0)).map_err(|err| NoNativeCertsError{ err })?;
406+
root_store
407+
.add(&rustls::Certificate(cert.0))
408+
.map_err(|err| NoNativeCertsError { err })?;
407409
}
408410

409411
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {

src/read.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,24 @@ where
142142
src.truncate(src.len() - 1); // Remove the newline
143143
src.unsplit(remainder);
144144
Ok(None)
145-
},
145+
}
146146
Ok(json) => {
147147
// Newline delimited json
148148
src.unsplit(remainder);
149149
src.advance(pos + 1);
150150
Ok(json)
151-
},
152-
Err(e) => Err(e)
151+
}
152+
Err(e) => Err(e),
153153
}
154-
155154
} else {
156-
// No newline delimited json.
155+
// No newline delimited json.
157156
match decode_json_from_slice(src) {
158157
Ok(None) => Ok(None),
159158
Ok(json) => {
160159
src.clear();
161160
Ok(json)
162-
},
163-
Err(e) => Err(e)
161+
}
162+
Err(e) => Err(e),
164163
}
165164
}
166165
} else {
@@ -341,7 +340,10 @@ mod tests {
341340
let mut buf = BytesMut::from(&b"\"foo\\nbar\""[..]);
342341
let mut codec: JsonLineDecoder<String> = JsonLineDecoder::new();
343342

344-
assert_eq!(codec.decode(&mut buf).unwrap(), Some(String::from("foo\nbar")));
343+
assert_eq!(
344+
codec.decode(&mut buf).unwrap(),
345+
Some(String::from("foo\nbar"))
346+
);
345347
}
346348

347349
#[test]

0 commit comments

Comments
 (0)