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

Commit0c24926

Browse files
committed
Add smol_str 0.2 support
1 parent6fd0444 commit0c24926

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
@@ -24,6 +24,7 @@ with-geo-types-0_7 = ["geo-types-0_7"]
2424
with-jiff-0_1 = ["jiff-01"]
2525
with-serde_json-1 = ["serde-1","serde_json-1"]
2626
with-smol_str-01 = ["smol_str-01"]
27+
with-smol_str-02 = ["smol_str-02"]
2728
with-uuid-0_8 = ["uuid-08"]
2829
with-uuid-1 = ["uuid-1"]
2930
with-time-0_2 = ["time-02"]
@@ -55,3 +56,4 @@ uuid-1 = { version = "1.0", package = "uuid", optional = true }
5556
time-02 = {version ="0.2",package ="time",optional =true }
5657
time-03 = {version ="0.3",package ="time",default-features =false,optional =true }
5758
smol_str-01 = {version ="0.1.23",package ="smol_str",default-features =false,optional =true }
59+
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
@@ -282,6 +282,8 @@ mod jiff_01;
282282
mod serde_json_1;
283283
#[cfg(feature ="with-smol_str-01")]
284284
mod smol_str_01;
285+
#[cfg(feature ="with-smol_str-02")]
286+
mod smol_str_02;
285287
#[cfg(feature ="with-time-0_2")]
286288
mod time_02;
287289
#[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