File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -584,6 +584,18 @@ impl<'a> FromSql<'a> for String {
584
584
}
585
585
}
586
586
587
+ impl < ' a > FromSql < ' a > for Box < str > {
588
+ fn from_sql ( _: & Type , raw : & ' a [ u8 ] ) -> Result < Box < str > , Box < dyn Error + Sync + Send > > {
589
+ types:: text_from_sql ( raw)
590
+ . map ( ToString :: to_string)
591
+ . map ( String :: into_boxed_str)
592
+ }
593
+
594
+ fn accepts ( ty : & Type ) -> bool {
595
+ <& str as FromSql >:: accepts ( ty)
596
+ }
597
+ }
598
+
587
599
impl < ' a > FromSql < ' a > for & ' a str {
588
600
fn from_sql ( _: & Type , raw : & ' a [ u8 ] ) -> Result < & ' a str , Box < dyn Error + Sync + Send > > {
589
601
types:: text_from_sql ( raw)
@@ -933,6 +945,18 @@ impl ToSql for String {
933
945
to_sql_checked ! ( ) ;
934
946
}
935
947
948
+ impl ToSql for Box < str > {
949
+ fn to_sql ( & self , ty : & Type , w : & mut BytesMut ) -> Result < IsNull , Box < dyn Error + Sync + Send > > {
950
+ <& str as ToSql >:: to_sql ( & & * * self , ty, w)
951
+ }
952
+
953
+ fn accepts ( ty : & Type ) -> bool {
954
+ <& str as ToSql >:: accepts ( ty)
955
+ }
956
+
957
+ to_sql_checked ! ( ) ;
958
+ }
959
+
936
960
macro_rules! simple_to {
937
961
( $t: ty, $f: ident, $( $expected: ident) ,+) => {
938
962
impl ToSql for $t {
You can’t perform that action at this time.
0 commit comments