Skip to content

Commit

Permalink
refactor(types): prefer matches! macro for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiDood committed Apr 7, 2023
1 parent a67fe64 commit 98abdf9
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions postgres-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,18 +1022,10 @@ impl<'a> ToSql for &'a str {
}

fn accepts(ty: &Type) -> bool {
match *ty {
Type::VARCHAR | Type::TEXT | Type::BPCHAR | Type::NAME | Type::UNKNOWN => true,
ref ty
if (ty.name() == "citext"
|| ty.name() == "ltree"
|| ty.name() == "lquery"
|| ty.name() == "ltxtquery") =>
{
true
}
_ => false,
}
matches!(
*ty,
Type::VARCHAR | Type::TEXT | Type::BPCHAR | Type::NAME | Type::UNKNOWN
) || matches!(ty.name(), "citext" | "ltree" | "lquery" | "ltxtquery")
}

to_sql_checked!();
Expand Down

0 comments on commit 98abdf9

Please sign in to comment.