From 636a0e2e178a95f0305c656e9be029a7ec0bfe92 Mon Sep 17 00:00:00 2001 From: Soham Zemse <22412996+zemse@users.noreply.github.com> Date: Tue, 2 Aug 2022 15:16:51 +0530 Subject: [PATCH] Allow hex strings without 0x prefix --- etk-cli/src/parse.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etk-cli/src/parse.rs b/etk-cli/src/parse.rs index 4f60c73a..9ace64b6 100644 --- a/etk-cli/src/parse.rs +++ b/etk-cli/src/parse.rs @@ -50,7 +50,11 @@ where type Err = FromHexError<::Error>; fn from_str(txt: &str) -> Result { - let rest = txt.strip_prefix("0x").ok_or(FromHexError::Prefix)?; + let rest = if txt.starts_with("0x") { + txt.strip_prefix("0x").unwrap() + } else { + txt + }; let item = T::from_hex(rest).map_err(FromHexError::Hex)?; Ok(Self(item)) }