diff --git a/rustybot/src/currency.rs b/rustybot/src/currency.rs index 87f02be..ae4a618 100644 --- a/rustybot/src/currency.rs +++ b/rustybot/src/currency.rs @@ -6,6 +6,7 @@ use std::fmt::{Display, Formatter}; use regex::Regex; use crate::BoxError; +use std::str::FromStr; #[derive(Clone, PartialEq, Hash, Debug, Eq)] pub struct Symbol { @@ -85,10 +86,10 @@ impl Into for SymbolPair { } } -impl TryFrom<&str> for SymbolPair { - type Error = BoxError; +impl FromStr for SymbolPair { + type Err = BoxError; - fn try_from(value: &str) -> Result { + fn from_str(value: &str) -> Result { const REGEX: &str = r"^[t|f](?P\w{3,7}):?(?P\w{3,7})"; let captures = Regex::new(REGEX)?.captures(&value).ok_or("Invalid input")?;