Skip to content

Commit b09e9cc

Browse files
authored
Add to_sql for bytes Cow as well
1 parent 4f41157 commit b09e9cc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

postgres-types/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,18 @@ impl<T: ToSql> ToSql for Box<[T]> {
10351035
to_sql_checked!();
10361036
}
10371037

1038+
impl<'a> ToSql for Cow<'a, [u8]> {
1039+
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
1040+
<&str as ToSql>::to_sql(&self.as_ref(), ty, w)
1041+
}
1042+
1043+
fn accepts(ty: &Type) -> bool {
1044+
<&[u8] as ToSql>::accepts(ty)
1045+
}
1046+
1047+
to_sql_checked!();
1048+
}
1049+
10381050
impl ToSql for Vec<u8> {
10391051
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
10401052
<&[u8] as ToSql>::to_sql(&&**self, ty, w)

0 commit comments

Comments
 (0)