Skip to content

Commit ff72557

Browse files
committed
minor: fix new clippy lint failures with rust 1.42.0
1 parent 37565be commit ff72557

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/bson_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) fn to_bson_array(docs: &[Document]) -> Bson {
2727

2828
#[cfg(test)]
2929
pub(crate) fn sort_document(document: &mut Document) {
30-
let temp = std::mem::replace(document, Default::default());
30+
let temp = std::mem::take(document);
3131

3232
let mut elements: Vec<_> = temp.into_iter().collect();
3333
elements.sort_by(|e1, e2| e1.0.cmp(&e2.0));

src/client/auth/scram.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ fn h_i<M: Mac + Sync>(str: &str, salt: &[u8], iterations: usize, output_size: us
299299

300300
/// Parses a string slice of the form "<expected_key>=<body>" into "<body>", if possible.
301301
fn parse_kvp(str: &str, expected_key: char) -> Result<String> {
302-
if str.chars().nth(0) != Some(expected_key) || str.chars().nth(1) != Some('=') {
302+
if !str.starts_with(expected_key) || str.chars().nth(1) != Some('=') {
303303
Err(Error::invalid_authentication_response("SCRAM"))
304304
} else {
305305
Ok(str.chars().skip(2).collect())
@@ -569,7 +569,7 @@ impl ServerFinal {
569569

570570
let first = message
571571
.chars()
572-
.nth(0)
572+
.next()
573573
.ok_or_else(|| Error::invalid_authentication_response("SCRAM"))?;
574574
let body = if first == ERROR_KEY {
575575
let error = parse_kvp(message, ERROR_KEY)?;

src/client/options/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ impl ClientOptionsParser {
839839
}
840840
}
841841

842-
let db_str = db.as_ref().map(String::as_str);
842+
let db_str = db.as_deref();
843843

844844
match options.auth_mechanism {
845845
Some(ref mechanism) => {

src/is_master.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl IsMasterCommandResponse {
6161
pub(crate) fn server_type(&self) -> ServerType {
6262
if self.ok != Some(1.0) {
6363
ServerType::Unknown
64-
} else if self.msg.as_ref().map(String::as_str) == Some("isdbgrid") {
64+
} else if self.msg.as_deref() == Some("isdbgrid") {
6565
ServerType::Mongos
6666
} else if self.set_name.is_some() {
6767
if let Some(true) = self.hidden {

src/sdam/public.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<'a> ServerInfo<'a> {
6464

6565
/// Gets the name of the replica set that the server is part of.
6666
pub fn replica_set_name(&self) -> Option<&str> {
67-
self.command_response_getter(|r| r.set_name.as_ref().map(String::as_str))
67+
self.command_response_getter(|r| r.set_name.as_deref())
6868
}
6969

7070
/// Gets the version of the replica set that the server is part of.

0 commit comments

Comments
 (0)