File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ where
120120/// impl in terms of `String`, but don't want to allocate. We have to return a
121121/// raw pointer instead of a reference with a lifetime due to the structure of
122122/// `FromSql`
123+ #[ cfg( not( feature = "unstable" ) ) ]
123124impl < DB > FromSql < sql_types:: Text , DB > for * const str
124125where
125126 DB : Backend + for < ' a > BinaryRawValue < ' a > ,
@@ -132,6 +133,19 @@ where
132133 }
133134}
134135
136+ #[ cfg( feature = "unstable" ) ]
137+ impl < DB > FromSql < sql_types:: Text , DB > for * const str
138+ where
139+ DB : Backend + for < ' a > BinaryRawValue < ' a > ,
140+ {
141+ default fn from_sql ( value : Option < :: backend:: RawValue < DB > > ) -> deserialize:: Result < Self > {
142+ use std:: str;
143+ let value = not_none ! ( value) ;
144+ let string = str:: from_utf8 ( DB :: as_bytes ( value) ) ?;
145+ Ok ( string as * const _ )
146+ }
147+ }
148+
135149impl < DB : Backend > ToSql < sql_types:: Text , DB > for str {
136150 fn to_sql < W : Write > ( & self , out : & mut Output < W , DB > ) -> serialize:: Result {
137151 out. write_all ( self . as_bytes ( ) )
You can’t perform that action at this time.
0 commit comments