Skip to content

Commit

Permalink
fix: use strip_prefix instead of starts_with
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Dec 29, 2020
1 parent 4665ebd commit 4283e5d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fixed-hash/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ macro_rules! impl_rustc_hex_for_fixed_hash {
/// - When encountering invalid non hex-digits
/// - Upon empty string input or invalid input length in general
fn from_str(input: &str) -> $crate::core_::result::Result<$name, $crate::rustc_hex::FromHexError> {
let input = if input.starts_with("0x") { &input[2..] } else { input };
let input = input.strip_prefix("0x").unwrap_or(input);
let mut iter = $crate::rustc_hex::FromHexIter::new(input);
let mut result = Self::zero();
for byte in result.as_mut() {
Expand Down
6 changes: 1 addition & 5 deletions uint/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1688,11 +1688,7 @@ macro_rules! construct_uint {
type Err = $crate::FromHexError;

fn from_str(value: &str) -> $crate::core_::result::Result<$name, Self::Err> {
let value = if value.starts_with("0x") {
&value[2..]
} else {
value
};
let value = value.strip_prefix("0x").unwrap_or(value);
const BYTES_LEN: usize = $n_words * 8;
const MAX_ENCODED_LEN: usize = BYTES_LEN * 2;

Expand Down

0 comments on commit 4283e5d

Please sign in to comment.