Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbeam committed Dec 24, 2024
1 parent 73976c1 commit 53c39f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
9 changes: 3 additions & 6 deletions src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,7 @@ impl Conn {
self.inner.capabilities = handshake.capabilities() & self.inner.opts.get_capabilities();
self.inner.version = handshake
.maria_db_server_version_parsed()
.map(|version| {
self.inner.is_mariadb = true;
version
})
.inspect(|_| self.inner.is_mariadb = true)
.or_else(|| handshake.server_version_parsed())
.unwrap_or((0, 0, 0));
self.inner.id = handshake.connection_id();
Expand Down Expand Up @@ -982,7 +979,7 @@ impl Conn {
/// Configures the connection based on server settings. In particular:
///
/// * It reads and stores socket address inside the connection unless if socket address is
/// already in [`Opts`] or if `prefer_socket` is `false`.
/// already in [`Opts`] or if `prefer_socket` is `false`.
///
/// * It reads and stores `max_allowed_packet` in the connection unless it's already in [`Opts`]
///
Expand Down Expand Up @@ -1429,7 +1426,7 @@ mod test {
let query = format!("CREATE USER 'test_user'@'%' IDENTIFIED WITH {}", plug);
conn.query_drop(query).await.unwrap();

if conn.inner.version <= (8, 0, 11) {
if conn.inner.version < (8, 0, 11) {
conn.query_drop(format!("SET old_passwords = {}", val))
.await
.unwrap();
Expand Down
3 changes: 2 additions & 1 deletion src/conn/pool/futures/disconnect_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ impl Future for DisconnectPool {
Some(drop) => match drop.send(None) {
Ok(_) => {
// Recycler is alive. Waiting for it to finish.
Poll::Ready(Ok(ready!(Box::pin(drop.closed()).as_mut().poll(cx))))
ready!(Box::pin(drop.closed()).as_mut().poll(cx));
Poll::Ready(Ok(()))
}
Err(_) => {
// Recycler seem dead. No one will wake us.
Expand Down
11 changes: 6 additions & 5 deletions src/opts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,8 +1376,7 @@ impl OptsBuilder {
/// Note that it'll saturate to proper minimum and maximum values
/// for this parameter (see MySql documentation).
pub fn max_allowed_packet(mut self, max_allowed_packet: Option<usize>) -> Self {
self.opts.max_allowed_packet =
max_allowed_packet.map(|x| std::cmp::max(1024, std::cmp::min(1073741824, x)));
self.opts.max_allowed_packet = max_allowed_packet.map(|x| x.clamp(1024, 1073741824));
self
}

Expand Down Expand Up @@ -1931,7 +1930,7 @@ impl FromStr for Opts {
}
}

impl<'a> TryFrom<&'a str> for Opts {
impl TryFrom<&str> for Opts {
type Error = UrlError;

fn try_from(s: &str) -> std::result::Result<Self, UrlError> {
Expand Down Expand Up @@ -1991,13 +1990,15 @@ mod test {

#[test]
fn should_convert_url_into_opts() {
let url = "mysql://usr:pw@192.168.1.1:3309/dbname";
let parsed_url = Url::parse("mysql://usr:pw@192.168.1.1:3309/dbname").unwrap();
let url = "mysql://usr:pw@192.168.1.1:3309/dbname?prefer_socket=true";
let parsed_url =
Url::parse("mysql://usr:pw@192.168.1.1:3309/dbname?prefer_socket=true").unwrap();

let mysql_opts = MysqlOpts {
user: Some("usr".to_string()),
pass: Some("pw".to_string()),
db_name: Some("dbname".to_string()),
prefer_socket: true,
..MysqlOpts::default()
};
let host = HostPortOrUrl::Url(parsed_url);
Expand Down

0 comments on commit 53c39f9

Please sign in to comment.