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

Commitd61eef2

Browse files
committed
Add smol_str 0.2 support
1 parente8f44ec commitd61eef2

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

‎postgres-types/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ with-geo-types-0_6 = ["geo-types-06"]
2222
with-geo-types-0_7 = ["geo-types-0_7"]
2323
with-serde_json-1 = ["serde-1","serde_json-1"]
2424
with-smol_str-01 = ["smol_str-01"]
25+
with-smol_str-02 = ["smol_str-02"]
2526
with-uuid-0_8 = ["uuid-08"]
2627
with-uuid-1 = ["uuid-1"]
2728
with-time-0_2 = ["time-02"]
@@ -52,3 +53,4 @@ uuid-1 = { version = "1.0", package = "uuid", optional = true }
5253
time-02 = {version ="0.2",package ="time",optional =true }
5354
time-03 = {version ="0.3",package ="time",default-features =false,optional =true }
5455
smol_str-01 = {version ="0.1.23",package ="smol_str",default-features =false,optional =true }
56+
smol_str-02 = {version ="0.2",package ="smol_str",default-features =false,optional =true }

‎postgres-types/src/lib.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ mod geo_types_07;
280280
mod serde_json_1;
281281
#[cfg(feature ="with-smol_str-01")]
282282
mod smol_str_01;
283+
#[cfg(feature ="with-smol_str-02")]
284+
mod smol_str_02;
283285
#[cfg(feature ="with-time-0_2")]
284286
mod time_02;
285287
#[cfg(feature ="with-time-0_3")]

‎postgres-types/src/smol_str_02.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use bytes::BytesMut;
2+
use smol_str_02::SmolStr;
3+
use std::error::Error;
4+
5+
usecrate::{FromSql,IsNull,ToSql,Type};
6+
7+
impl<'a>FromSql<'a>forSmolStr{
8+
fnfrom_sql(ty:&Type,raw:&'a[u8]) ->Result<Self,Box<dynError +Sync +Send>>{
9+
Ok(SmolStr::new(<&strasFromSql>::from_sql(ty, raw)?))
10+
}
11+
12+
fnaccepts(ty:&Type) ->bool{
13+
<&strasFromSql>::accepts(ty)
14+
}
15+
}
16+
17+
implToSqlforSmolStr{
18+
fnto_sql(&self,ty:&Type,out:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
19+
<&strasToSql>::to_sql(&self.as_str(), ty, out)
20+
}
21+
22+
fnaccepts(ty:&Type) ->bool{
23+
<&strasToSql>::accepts(ty)
24+
}
25+
26+
to_sql_checked!();
27+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp