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

usesplit_once instead ofsplit to parse lsn strings#1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletionspostgres-types/CHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
# Change Log

## Unreleased

### Changed

* `FromStr` implementation for `PgLsn` no longer allocates a `Vec` when splitting an lsn string on it's `/`.

## v0.2.6 - 2023-08-19

### Fixed
Expand Down
18 changes: 8 additions & 10 deletionspostgres-types/src/pg_lsn.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,16 +33,14 @@ impl FromStr for PgLsn {
type Err = ParseLsnError;

fn from_str(lsn_str: &str) -> Result<Self, Self::Err> {
let split: Vec<&str> = lsn_str.split('/').collect();
if split.len() == 2 {
let (hi, lo) = (
u64::from_str_radix(split[0], 16).map_err(|_| ParseLsnError(()))?,
u64::from_str_radix(split[1], 16).map_err(|_| ParseLsnError(()))?,
);
Ok(PgLsn((hi << 32) | lo))
} else {
Err(ParseLsnError(()))
}
let Some((split_hi, split_lo)) = lsn_str.split_once('/') else {
return Err(ParseLsnError(()));
};
let (hi, lo) = (
u64::from_str_radix(split_hi, 16).map_err(|_| ParseLsnError(()))?,
u64::from_str_radix(split_lo, 16).map_err(|_| ParseLsnError(()))?,
);
Ok(PgLsn((hi << 32) | lo))
}
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp