Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b9b5d0

Browse files
authored
Merge pull request#1018 from BastiDood/str-to-sql-refactor
refactor(types): improve readability of `impl ToSql for &str`
2 parents7dd6813 +98abdf9 commit8b9b5d0

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

‎postgres-types/src/lib.rs‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,28 +1012,20 @@ impl ToSql for Vec<u8> {
10121012

10131013
impl<'a>ToSqlfor&'astr{
10141014
fnto_sql(&self,ty:&Type,w:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
1015-
match*ty{
1016-
ref tyif ty.name() =="ltree" => types::ltree_to_sql(self, w),
1017-
ref tyif ty.name() =="lquery" => types::lquery_to_sql(self, w),
1018-
ref tyif ty.name() =="ltxtquery" => types::ltxtquery_to_sql(self, w),
1015+
matchty.name(){
1016+
"ltree" => types::ltree_to_sql(self, w),
1017+
"lquery" => types::lquery_to_sql(self, w),
1018+
"ltxtquery" => types::ltxtquery_to_sql(self, w),
10191019
_ => types::text_to_sql(self, w),
10201020
}
10211021
Ok(IsNull::No)
10221022
}
10231023

10241024
fnaccepts(ty:&Type) ->bool{
1025-
match*ty{
1026-
Type::VARCHAR |Type::TEXT |Type::BPCHAR |Type::NAME |Type::UNKNOWN =>true,
1027-
ref ty
1028-
if(ty.name() =="citext"
1029-
|| ty.name() =="ltree"
1030-
|| ty.name() =="lquery"
1031-
|| ty.name() =="ltxtquery") =>
1032-
{
1033-
true
1034-
}
1035-
_ =>false,
1036-
}
1025+
matches!(
1026+
*ty,
1027+
Type::VARCHAR |Type::TEXT |Type::BPCHAR |Type::NAME |Type::UNKNOWN
1028+
) ||matches!(ty.name(),"citext" |"ltree" |"lquery" |"ltxtquery")
10371029
}
10381030

10391031
to_sql_checked!();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp