Skip to content

Commit

Permalink
crypto: simplify split usage [trivial] (#10285)
Browse files Browse the repository at this point in the history
  • Loading branch information
mina86 authored Dec 4, 2023
1 parent cf2700e commit 1ef2364
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/crypto/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ impl TryFrom<u8> for KeyType {
}

fn split_key_type_data(value: &str) -> Result<(KeyType, &str), crate::errors::ParseKeyTypeError> {
if let Some(idx) = value.find(':') {
let (prefix, key_data) = value.split_at(idx);
Ok((KeyType::from_str(prefix)?, &key_data[1..]))
if let Some((prefix, key_data)) = value.split_once(':') {
Ok((KeyType::from_str(prefix)?, key_data))
} else {
// If there is no prefix then we Default to ED25519.
Ok((KeyType::ED25519, value))
Expand Down

0 comments on commit 1ef2364

Please sign in to comment.