rust #10

Merged
peperunas merged 127 commits from rust into master 2021-02-18 09:42:16 +00:00
Showing only changes of commit 85c02e4053 - Show all commits

View File

@ -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<String> for SymbolPair {
}
}
impl TryFrom<&str> for SymbolPair {
type Error = BoxError;
impl FromStr for SymbolPair {
type Err = BoxError;
fn try_from(value: &str) -> Result<Self, Self::Error> {
fn from_str(value: &str) -> Result<Self, Self::Err> {
const REGEX: &str = r"^[t|f](?P<base>\w{3,7}):?(?P<quote>\w{3,7})";
let captures = Regex::new(REGEX)?.captures(&value).ok_or("Invalid input")?;