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

Commite528e01

Browse files
authored
Merge pull request#1118 from laxjesse/split_once_in_lsn_from_str
use `split_once` instead of `split` to parse lsn strings
2 parents270a29b +9743630 commite528e01

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

‎postgres-types/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#Change Log
22

3+
##Unreleased
4+
5+
###Changed
6+
7+
*`FromStr` implementation for`PgLsn` no longer allocates a`Vec` when splitting an lsn string on it's`/`.
8+
39
##v0.2.6 - 2023-08-19
410

511
###Fixed

‎postgres-types/src/pg_lsn.rs‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@ impl FromStr for PgLsn {
3333
typeErr =ParseLsnError;
3434

3535
fnfrom_str(lsn_str:&str) ->Result<Self,Self::Err>{
36-
let split:Vec<&str> = lsn_str.split('/').collect();
37-
if split.len() ==2{
38-
let(hi, lo) =(
39-
u64::from_str_radix(split[0],16).map_err(|_|ParseLsnError(()))?,
40-
u64::from_str_radix(split[1],16).map_err(|_|ParseLsnError(()))?,
41-
);
42-
Ok(PgLsn((hi <<32) | lo))
43-
}else{
44-
Err(ParseLsnError(()))
45-
}
36+
letSome((split_hi, split_lo)) = lsn_str.split_once('/')else{
37+
returnErr(ParseLsnError(()));
38+
};
39+
let(hi, lo) =(
40+
u64::from_str_radix(split_hi,16).map_err(|_|ParseLsnError(()))?,
41+
u64::from_str_radix(split_lo,16).map_err(|_|ParseLsnError(()))?,
42+
);
43+
Ok(PgLsn((hi <<32) | lo))
4644
}
4745
}
4846

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp