Skip to content

Commit 23f2a5d

Browse files
committed
minor: fix clippy
1 parent 9881419 commit 23f2a5d

File tree

28 files changed

+85
-84
lines changed

28 files changed

+85
-84
lines changed

src/client/auth/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ pub(crate) enum ClientFirst {
454454
impl ClientFirst {
455455
pub(crate) fn to_document(&self) -> Document {
456456
match self {
457-
Self::Scram(version, client_first) => client_first.to_command(&version).body,
457+
Self::Scram(version, client_first) => client_first.to_command(version).body,
458458
Self::X509(command) => command.body.clone(),
459459
}
460460
}

src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl Client {
285285
message: self
286286
.inner
287287
.topology
288-
.server_selection_timeout_error_message(&criteria)
288+
.server_selection_timeout_error_message(criteria)
289289
.await,
290290
}
291291
.into());

src/client/options/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ impl ClientOptionsParser {
11901190
credential.mechanism_properties = Some(doc);
11911191
}
11921192

1193-
mechanism.validate_credential(&credential)?;
1193+
mechanism.validate_credential(credential)?;
11941194
credential.mechanism = options.auth_mechanism.take();
11951195
}
11961196
None => {

src/cmap/conn/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl CommandResponse {
113113
/// Returns whether this response indicates a success or not (i.e. if "ok: 1")
114114
pub(crate) fn is_success(&self) -> bool {
115115
match self.raw_response.get("ok") {
116-
Some(ref b) => bson_util::get_int(b) == Some(1),
116+
Some(b) => bson_util::get_int(b) == Some(1),
117117
_ => false,
118118
}
119119
}

src/cmap/test/event.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,34 +134,40 @@ impl EventSubscriber<'_> {
134134
#[derive(Clone, Debug, Deserialize, From, PartialEq)]
135135
#[serde(tag = "type")]
136136
pub enum Event {
137-
#[serde(deserialize_with = "self::deserialize_pool_created")]
138-
ConnectionPoolCreated(PoolCreatedEvent),
139-
ConnectionPoolClosed(PoolClosedEvent),
140-
ConnectionPoolReady(PoolReadyEvent),
137+
#[serde(
138+
deserialize_with = "self::deserialize_pool_created",
139+
rename = "ConnectionPoolCreated"
140+
)]
141+
PoolCreated(PoolCreatedEvent),
142+
#[serde(rename = "ConnectionPoolClosed")]
143+
PoolClosed(PoolClosedEvent),
144+
#[serde(rename = "ConnectionPoolReady")]
145+
PoolReady(PoolReadyEvent),
141146
ConnectionCreated(ConnectionCreatedEvent),
142147
ConnectionReady(ConnectionReadyEvent),
143148
ConnectionClosed(ConnectionClosedEvent),
144149
ConnectionCheckOutStarted(ConnectionCheckoutStartedEvent),
145150
#[serde(deserialize_with = "self::deserialize_checkout_failed")]
146151
ConnectionCheckOutFailed(ConnectionCheckoutFailedEvent),
147152
ConnectionCheckedOut(ConnectionCheckedOutEvent),
148-
ConnectionPoolCleared(PoolClearedEvent),
153+
#[serde(rename = "ConnectionPoolCleared")]
154+
PoolCleared(PoolClearedEvent),
149155
ConnectionCheckedIn(ConnectionCheckedInEvent),
150156
}
151157

152158
impl Event {
153159
pub fn name(&self) -> &'static str {
154160
match self {
155-
Event::ConnectionPoolCreated(_) => "ConnectionPoolCreated",
156-
Event::ConnectionPoolReady(_) => "ConnectionPoolReady",
157-
Event::ConnectionPoolClosed(_) => "ConnectionPoolClosed",
161+
Event::PoolCreated(_) => "ConnectionPoolCreated",
162+
Event::PoolReady(_) => "ConnectionPoolReady",
163+
Event::PoolClosed(_) => "ConnectionPoolClosed",
158164
Event::ConnectionCreated(_) => "ConnectionCreated",
159165
Event::ConnectionReady(_) => "ConnectionReady",
160166
Event::ConnectionClosed(_) => "ConnectionClosed",
161167
Event::ConnectionCheckOutStarted(_) => "ConnectionCheckOutStarted",
162168
Event::ConnectionCheckOutFailed(_) => "ConnectionCheckOutFailed",
163169
Event::ConnectionCheckedOut(_) => "ConnectionCheckedOut",
164-
Event::ConnectionPoolCleared(_) => "ConnectionPoolCleared",
170+
Event::PoolCleared(_) => "ConnectionPoolCleared",
165171
Event::ConnectionCheckedIn(_) => "ConnectionCheckedIn",
166172
}
167173
}

src/cmap/test/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async fn concurrent_connections() {
8282
let client = TestClient::with_options(Some(options), true).await;
8383
let version = VersionReq::parse(">= 4.2.9").unwrap();
8484
// blockConnection failpoint option only supported in 4.2.9+.
85-
if !version.matches(&client.server_version.as_ref().unwrap()) {
85+
if !version.matches(client.server_version.as_ref().unwrap()) {
8686
println!(
8787
"skipping concurrent_connections test due to server not supporting failpoint option"
8888
);

src/cmap/test/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ impl Operation {
309309

310310
// wait for event to be emitted to ensure drop has completed.
311311
subscriber
312-
.wait_for_event(EVENT_TIMEOUT, |e| {
313-
matches!(e, Event::ConnectionPoolClosed(_))
314-
})
312+
.wait_for_event(EVENT_TIMEOUT, |e| matches!(e, Event::PoolClosed(_)))
315313
.await
316314
.expect("did not receive ConnectionPoolClosed event after closing pool");
317315
}
@@ -356,7 +354,7 @@ impl Matchable for ConnectionPoolOptions {
356354
impl Matchable for Event {
357355
fn content_matches(&self, expected: &Event) -> bool {
358356
match (self, expected) {
359-
(Event::ConnectionPoolCreated(actual), Event::ConnectionPoolCreated(ref expected)) => {
357+
(Event::PoolCreated(actual), Event::PoolCreated(ref expected)) => {
360358
actual.options.matches(&expected.options)
361359
}
362360
(Event::ConnectionCreated(actual), Event::ConnectionCreated(ref expected)) => {
@@ -380,9 +378,9 @@ impl Matchable for Event {
380378
Event::ConnectionCheckOutFailed(ref expected),
381379
) => actual.reason == expected.reason,
382380
(Event::ConnectionCheckOutStarted(_), Event::ConnectionCheckOutStarted(_)) => true,
383-
(Event::ConnectionPoolCleared(_), Event::ConnectionPoolCleared(_)) => true,
384-
(Event::ConnectionPoolReady(_), Event::ConnectionPoolReady(_)) => true,
385-
(Event::ConnectionPoolClosed(_), Event::ConnectionPoolClosed(_)) => true,
381+
(Event::PoolCleared(_), Event::PoolCleared(_)) => true,
382+
(Event::PoolReady(_), Event::PoolReady(_)) => true,
383+
(Event::PoolClosed(_), Event::PoolClosed(_)) => true,
386384
_ => false,
387385
}
388386
}
@@ -464,7 +462,7 @@ async fn redact_credential() {
464462

465463
subscriber
466464
.wait_for_event(EVENT_TIMEOUT, |e| {
467-
if let crate::test::Event::CmapEvent(CmapEvent::ConnectionPoolCreated(event)) = e {
465+
if let crate::test::Event::CmapEvent(CmapEvent::PoolCreated(event)) = e {
468466
let event_debug = format!("{:?}", event);
469467
if let Some(ref pass) = credential.password {
470468
assert!(!event_debug.contains(pass))

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Error {
9797
}
9898
match &self.kind.code_and_message() {
9999
Some((code, message)) => {
100-
if RETRYABLE_READ_CODES.contains(&code) {
100+
if RETRYABLE_READ_CODES.contains(code) {
101101
return true;
102102
}
103103
if is_not_master(*code, message) || is_recovering(*code, message) {
@@ -125,7 +125,7 @@ impl Error {
125125
return true;
126126
}
127127
match &self.kind.code_and_message() {
128-
Some((code, _)) => RETRYABLE_WRITE_CODES.contains(&code),
128+
Some((code, _)) => RETRYABLE_WRITE_CODES.contains(code),
129129
None => false,
130130
}
131131
}

src/operation/insert/test.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ async fn build() {
7373

7474
for (original_doc, cmd_doc) in fixtures.documents.iter().zip(cmd_docs.iter_mut()) {
7575
assert!(cmd_doc.get("_id").is_some());
76-
if original_doc.get("_id").is_some() {
77-
assert_eq!(original_doc, cmd_doc);
78-
} else {
76+
if !original_doc.get("_id").is_some() {
7977
cmd_doc.remove("_id");
80-
assert_eq!(original_doc, cmd_doc);
81-
};
78+
}
79+
assert_eq!(original_doc, cmd_doc);
8280
}
8381

8482
assert_eq!(

src/runtime/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl AsyncTcpStream {
9292
let socket = Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?;
9393
socket.set_keepalive(Some(KEEPALIVE_TIME))?;
9494

95-
let address: SockAddr = address.clone().into();
95+
let address: SockAddr = (*address).into();
9696
if connect_timeout == Duration::from_secs(0) {
9797
socket.connect(&address)?;
9898
} else {

0 commit comments

Comments
 (0)