Skip to content

Commit 62535fa

Browse files
committed
fix: resolve redundant closures and more auto-deref warnings
- Remove redundant closures in lquery and ltree types - Fix auto-deref issues in postgres options parser - Fix auto-deref issues in postgres type_info
1 parent 1ae9134 commit 62535fa

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

sqlx-core/src/postgres/options/parse.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ impl FromStr for PgConnectOptions {
4848
}
4949

5050
for (key, value) in url.query_pairs().into_iter() {
51-
match &*key {
51+
match &key as &str {
5252
"sslmode" | "ssl-mode" => {
5353
options = options.ssl_mode(value.parse().map_err(Error::config)?);
5454
}
5555

5656
"sslrootcert" | "ssl-root-cert" | "ssl-ca" => {
57-
options = options.ssl_root_cert(&*value);
57+
options = options.ssl_root_cert(&value);
5858
}
5959

60-
"sslcert" | "ssl-cert" => options = options.ssl_client_cert(&*value),
60+
"sslcert" | "ssl-cert" => options = options.ssl_client_cert(&value),
6161

62-
"sslkey" | "ssl-key" => options = options.ssl_client_key(&*value),
62+
"sslkey" | "ssl-key" => options = options.ssl_client_key(&value),
6363

6464
"statement-cache-capacity" => {
6565
options =
@@ -68,39 +68,39 @@ impl FromStr for PgConnectOptions {
6868

6969
"host" => {
7070
if value.starts_with("/") {
71-
options = options.socket(&*value);
71+
options = options.socket(&value);
7272
} else {
73-
options = options.host(&*value);
73+
options = options.host(&value);
7474
}
7575
}
7676

7777
"hostaddr" => {
7878
value.parse::<IpAddr>().map_err(Error::config)?;
79-
options = options.host(&*value)
79+
options = options.host(&value)
8080
}
8181

8282
"port" => options = options.port(value.parse().map_err(Error::config)?),
8383

84-
"dbname" => options = options.database(&*value),
84+
"dbname" => options = options.database(&value),
8585

86-
"user" => options = options.username(&*value),
86+
"user" => options = options.username(&value),
8787

88-
"password" => options = options.password(&*value),
88+
"password" => options = options.password(&value),
8989

90-
"application_name" => options = options.application_name(&*value),
90+
"application_name" => options = options.application_name(&value),
9191

9292
"options" => {
9393
if let Some(options) = options.options.as_mut() {
9494
options.push(' ');
95-
options.push_str(&*value);
95+
options.push_str(&value);
9696
} else {
9797
options.options = Some(value.to_string());
9898
}
9999
}
100100

101101
k if k.starts_with("options[") => {
102102
if let Some(key) = k.strip_prefix("options[").unwrap().strip_suffix(']') {
103-
options = options.options([(key, &*value)]);
103+
options = options.options([(key, &value)]);
104104
}
105105
}
106106

sqlx-core/src/postgres/type_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl PgType {
540540
PgType::Money => "MONEY",
541541
PgType::MoneyArray => "MONEY[]",
542542
PgType::Void => "VOID",
543-
PgType::Custom(ty) => &*ty.name,
543+
PgType::Custom(ty) => &ty.name,
544544
PgType::DeclareWithOid(_) => "?",
545545
PgType::DeclareWithName(name) => name,
546546
}
@@ -640,7 +640,7 @@ impl PgType {
640640
PgType::Money => "money",
641641
PgType::MoneyArray => "_money",
642642
PgType::Void => "void",
643-
PgType::Custom(ty) => &*ty.name,
643+
PgType::Custom(ty) => &ty.name,
644644
PgType::DeclareWithOid(_) => "?",
645645
PgType::DeclareWithName(name) => name,
646646
}

sqlx-core/src/postgres/types/lquery.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl FromStr for PgLQuery {
104104
Ok(Self {
105105
levels: s
106106
.split('.')
107-
.map(|s| PgLQueryLevel::from_str(s))
107+
.map(PgLQueryLevel::from_str)
108108
.collect::<Result<_, Self::Err>>()?,
109109
})
110110
}
@@ -245,12 +245,12 @@ impl FromStr for PgLQueryLevel {
245245
b'!' => Ok(PgLQueryLevel::NotNonStar(
246246
s[1..]
247247
.split('|')
248-
.map(|s| PgLQueryVariant::from_str(s))
248+
.map(PgLQueryVariant::from_str)
249249
.collect::<Result<Vec<_>, PgLQueryParseError>>()?,
250250
)),
251251
_ => Ok(PgLQueryLevel::NonStar(
252252
s.split('|')
253-
.map(|s| PgLQueryVariant::from_str(s))
253+
.map(PgLQueryVariant::from_str)
254254
.collect::<Result<Vec<_>, PgLQueryParseError>>()?,
255255
)),
256256
}

sqlx-core/src/postgres/types/ltree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl FromStr for PgLTree {
142142
Ok(Self {
143143
labels: s
144144
.split('.')
145-
.map(|s| PgLTreeLabel::new(s))
145+
.map(PgLTreeLabel::new)
146146
.collect::<Result<Vec<_>, Self::Err>>()?,
147147
})
148148
}

0 commit comments

Comments
 (0)