Skip to content

Commit

Permalink
Merge pull request #309 from yhx-12243/strip-prefix
Browse files Browse the repository at this point in the history
style: use strip_prefix instead of manual starts_with/slice
  • Loading branch information
cuviper committed May 29, 2024
2 parents 71b78bc + 635c687 commit 124eac8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/bigint/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ impl Num for BigInt {
/// Creates and initializes a [`BigInt`].
#[inline]
fn from_str_radix(mut s: &str, radix: u32) -> Result<BigInt, ParseBigIntError> {
let sign = if s.starts_with('-') {
let tail = &s[1..];
let sign = if let Some(tail) = s.strip_prefix('-') {
if !tail.starts_with('+') {
s = tail
}
Expand Down
3 changes: 1 addition & 2 deletions src/biguint/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ impl Num for BigUint {
fn from_str_radix(s: &str, radix: u32) -> Result<BigUint, ParseBigIntError> {
assert!(2 <= radix && radix <= 36, "The radix must be within 2...36");
let mut s = s;
if s.starts_with('+') {
let tail = &s[1..];
if let Some(tail) = s.strip_prefix('+') {
if !tail.starts_with('+') {
s = tail
}
Expand Down

0 comments on commit 124eac8

Please sign in to comment.