Skip to content

Commit 399816d

Browse files
committed
Fix a number of lints raised by clippy when running tests.
1 parent 99c706a commit 399816d

13 files changed

+80
-96
lines changed

examples/ha_producer.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl MyHAProducer {
101101
ProducerPublishError::Timeout | ProducerPublishError::Closed => {
102102
Box::pin(self.send_with_confirm(message)).await
103103
}
104-
_ => return Err(e),
104+
_ => Err(e),
105105
},
106106
}
107107
}
@@ -114,14 +114,12 @@ async fn ensure_stream_exists(environment: &Environment, stream: &str) -> Rabbit
114114
.create(stream)
115115
.await;
116116

117-
if let Err(e) = create_response {
118-
if let StreamCreateError::Create { stream, status } = e {
119-
match status {
120-
// we can ignore this error because the stream already exists
121-
ResponseCode::StreamAlreadyExists => {}
122-
err => {
123-
panic!("Error creating stream: {:?} {:?}", stream, err);
124-
}
117+
if let Err(StreamCreateError::Create { stream, status }) = create_response {
118+
match status {
119+
// we can ignore this error because the stream already exists
120+
ResponseCode::StreamAlreadyExists => {}
121+
err => {
122+
panic!("Error creating stream: {:?} {:?}", stream, err);
125123
}
126124
}
127125
}

examples/send_async.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3535
.create(stream)
3636
.await;
3737

38-
if let Err(e) = create_response {
39-
if let StreamCreateError::Create { stream, status } = e {
40-
match status {
41-
// we can ignore this error because the stream already exists
42-
ResponseCode::StreamAlreadyExists => {}
43-
err => {
44-
println!("Error creating stream: {:?} {:?}", stream, err);
45-
}
38+
if let Err(StreamCreateError::Create { stream, status }) = create_response {
39+
match status {
40+
// we can ignore this error because the stream already exists
41+
ResponseCode::StreamAlreadyExists => {}
42+
err => {
43+
println!("Error creating stream: {:?} {:?}", stream, err);
4644
}
4745
}
4846
}

examples/send_with_confirm.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1313
.create(stream)
1414
.await;
1515

16-
if let Err(e) = create_response {
17-
if let StreamCreateError::Create { stream, status } = e {
18-
match status {
19-
// we can ignore this error because the stream already exists
20-
ResponseCode::StreamAlreadyExists => {}
21-
err => {
22-
println!("Error creating stream: {:?} {:?}", stream, err);
23-
}
16+
if let Err(StreamCreateError::Create { stream, status }) = create_response {
17+
match status {
18+
// we can ignore this error because the stream already exists
19+
ResponseCode::StreamAlreadyExists => {}
20+
err => {
21+
println!("Error creating stream: {:?} {:?}", stream, err);
2422
}
2523
}
2624
}

examples/simple-consumer.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1414
.create(stream)
1515
.await;
1616

17-
if let Err(e) = create_response {
18-
if let StreamCreateError::Create { stream, status } = e {
19-
match status {
20-
// we can ignore this error because the stream already exists
21-
ResponseCode::StreamAlreadyExists => {}
22-
err => {
23-
println!("Error creating stream: {:?} {:?}", stream, err);
24-
}
17+
if let Err(StreamCreateError::Create { stream, status }) = create_response {
18+
match status {
19+
// we can ignore this error because the stream already exists
20+
ResponseCode::StreamAlreadyExists => {}
21+
err => {
22+
println!("Error creating stream: {:?} {:?}", stream, err);
2523
}
2624
}
2725
}

examples/superstreams/receive_super_stream.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1717
.create_super_stream(super_stream, 3, None)
1818
.await;
1919

20-
if let Err(e) = create_response {
21-
if let StreamCreateError::Create { stream, status } = e {
22-
match status {
23-
// we can ignore this error because the stream already exists
24-
ResponseCode::StreamAlreadyExists => {}
25-
err => {
26-
println!("Error creating stream: {:?} {:?}", stream, err);
27-
}
20+
if let Err(StreamCreateError::Create { stream, status }) = create_response {
21+
match status {
22+
// we can ignore this error because the stream already exists
23+
ResponseCode::StreamAlreadyExists => {}
24+
err => {
25+
println!("Error creating stream: {:?} {:?}", stream, err);
2826
}
2927
}
3028
}

examples/superstreams/send_super_stream.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5252
.create_super_stream(super_stream, 3, None)
5353
.await;
5454

55-
if let Err(e) = create_response {
56-
if let StreamCreateError::Create { stream, status } = e {
57-
match status {
58-
// we can ignore this error because the stream already exists
59-
ResponseCode::StreamAlreadyExists => {}
60-
err => {
61-
println!("Error creating stream: {:?} {:?}", stream, err);
62-
}
55+
if let Err(StreamCreateError::Create { stream, status }) = create_response {
56+
match status {
57+
// we can ignore this error because the stream already exists
58+
ResponseCode::StreamAlreadyExists => {}
59+
err => {
60+
println!("Error creating stream: {:?} {:?}", stream, err);
6361
}
6462
}
6563
}

examples/superstreams/send_super_stream_hash.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5454
.create_super_stream(super_stream, 3, None)
5555
.await;
5656

57-
if let Err(e) = create_response {
58-
if let StreamCreateError::Create { stream, status } = e {
59-
match status {
60-
// we can ignore this error because the stream already exists
61-
ResponseCode::StreamAlreadyExists => {}
62-
err => {
63-
println!("Error creating stream: {:?} {:?}", stream, err);
64-
}
57+
if let Err(StreamCreateError::Create { stream, status }) = create_response {
58+
match status {
59+
// we can ignore this error because the stream already exists
60+
ResponseCode::StreamAlreadyExists => {}
61+
err => {
62+
println!("Error creating stream: {:?} {:?}", stream, err);
6563
}
6664
}
6765
}

examples/superstreams/send_super_stream_routing_key.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5454
.create_super_stream(super_stream, 3, Some(routing_key))
5555
.await;
5656

57-
if let Err(e) = create_response {
58-
if let StreamCreateError::Create { stream, status } = e {
59-
match status {
60-
// we can ignore this error because the stream already exists
61-
ResponseCode::StreamAlreadyExists => {}
62-
err => {
63-
println!("Error creating stream: {:?} {:?}", stream, err);
64-
}
57+
if let Err(StreamCreateError::Create { stream, status }) = create_response {
58+
match status {
59+
// we can ignore this error because the stream already exists
60+
ResponseCode::StreamAlreadyExists => {}
61+
err => {
62+
println!("Error creating stream: {:?} {:?}", stream, err);
6563
}
6664
}
6765
}

examples/tls_producer.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5050
Ok(())
5151
}
5252

53-
async fn start_publisher(
54-
env: Environment,
55-
stream: &String,
56-
) -> Result<(), Box<dyn std::error::Error>> {
53+
async fn start_publisher(env: Environment, stream: &str) -> Result<(), Box<dyn std::error::Error>> {
5754
let _ = env.stream_creator().create(stream).await;
5855

5956
let producer = env.producer().batch_size(BATCH_SIZE).build(stream).await?;

src/stream_creator.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,11 @@ impl StreamCreator {
4141
binding_keys: Option<Vec<String>>,
4242
) -> Result<(), StreamCreateError> {
4343
let mut partitions_names = Vec::with_capacity(number_of_partitions);
44-
let mut new_binding_keys: Vec<String> = Vec::with_capacity(number_of_partitions);
44+
let new_binding_keys = binding_keys
45+
.unwrap_or_else(|| (0..number_of_partitions).map(|i| i.to_string()).collect());
4546

46-
if binding_keys.is_none() {
47-
for i in 0..number_of_partitions {
48-
new_binding_keys.push(i.to_string());
49-
partitions_names.push(super_stream.to_owned() + "-" + i.to_string().as_str())
50-
}
51-
} else {
52-
new_binding_keys = binding_keys.unwrap();
53-
for binding_key in new_binding_keys.iter() {
54-
partitions_names.push(super_stream.to_owned() + "-" + binding_key)
55-
}
47+
for binding_key in new_binding_keys.iter() {
48+
partitions_names.push(super_stream.to_owned() + "-" + binding_key)
5649
}
5750

5851
let client = self.env.create_client().await?;

0 commit comments

Comments
 (0)