Skip to content

Commit 635c687

Browse files
committed
style: use strip_prefix instead of manual starts_with/slice
1 parent 71b78bc commit 635c687

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/bigint/convert.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ impl Num for BigInt {
2525
/// Creates and initializes a [`BigInt`].
2626
#[inline]
2727
fn from_str_radix(mut s: &str, radix: u32) -> Result<BigInt, ParseBigIntError> {
28-
let sign = if s.starts_with('-') {
29-
let tail = &s[1..];
28+
let sign = if let Some(tail) = s.strip_prefix('-') {
3029
if !tail.starts_with('+') {
3130
s = tail
3231
}

src/biguint/convert.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ impl Num for BigUint {
221221
fn from_str_radix(s: &str, radix: u32) -> Result<BigUint, ParseBigIntError> {
222222
assert!(2 <= radix && radix <= 36, "The radix must be within 2...36");
223223
let mut s = s;
224-
if s.starts_with('+') {
225-
let tail = &s[1..];
224+
if let Some(tail) = s.strip_prefix('+') {
226225
if !tail.starts_with('+') {
227226
s = tail
228227
}

0 commit comments

Comments
 (0)