Skip to content

Commit

Permalink
no early return
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx committed May 25, 2023
1 parent 1821685 commit e8cdc87
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/account-id/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,18 @@ impl<'a> arbitrary::Arbitrary<'a> for AccountId {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let s = u.arbitrary::<&str>()?;
match s.parse::<AccountId>() {
Ok(account_id) => return Ok(account_id),
Ok(account_id) => Ok(account_id),
Err(e) => {
if let Some((valid_up_to, _)) = e.char {
let valid = &s[..valid_up_to];
debug_assert!(AccountId::validate(valid).is_ok());
#[allow(deprecated)]
return Ok(AccountId::new_unvalidated(valid.to_string()));
Ok(AccountId::new_unvalidated(valid.to_string()));
} else {
Err(arbitrary::Error::IncorrectFormat)
}
}
}
Err(arbitrary::Error::IncorrectFormat)
}

fn arbitrary_take_rest(u: arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
Expand Down

0 comments on commit e8cdc87

Please sign in to comment.