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

Commit35f4c0a

Browse files
committed
ImplementToSql &FromSql forBox<str>
1 parent630f179 commit35f4c0a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎postgres-types/src/lib.rs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,18 @@ impl<'a> FromSql<'a> for String {
584584
}
585585
}
586586

587+
impl<'a>FromSql<'a>forBox<str>{
588+
fnfrom_sql(_:&Type,raw:&'a[u8]) ->Result<Box<str>,Box<dynError +Sync +Send>>{
589+
types::text_from_sql(raw)
590+
.map(ToString::to_string)
591+
.map(String::into_boxed_str)
592+
}
593+
594+
fnaccepts(ty:&Type) ->bool{
595+
<&strasFromSql>::accepts(ty)
596+
}
597+
}
598+
587599
impl<'a>FromSql<'a>for&'astr{
588600
fnfrom_sql(_:&Type,raw:&'a[u8]) ->Result<&'astr,Box<dynError +Sync +Send>>{
589601
types::text_from_sql(raw)
@@ -933,6 +945,18 @@ impl ToSql for String {
933945
to_sql_checked!();
934946
}
935947

948+
implToSqlforBox<str>{
949+
fnto_sql(&self,ty:&Type,w:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
950+
<&strasToSql>::to_sql(&&**self, ty, w)
951+
}
952+
953+
fnaccepts(ty:&Type) ->bool{
954+
<&strasToSql>::accepts(ty)
955+
}
956+
957+
to_sql_checked!();
958+
}
959+
936960
macro_rules! simple_to{
937961
($t:ty, $f:ident, $($expected:ident),+) =>{
938962
implToSqlfor $t{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp