Remove another unnecessary method

This commit is contained in:
Jeremy Wall 2021-11-17 19:36:16 -05:00
parent c5d5e7e536
commit a7923fbcf3

View File

@ -15,12 +15,10 @@ pub mod parse;
pub mod unit;
use std::collections::BTreeMap;
use std::str::FromStr;
use chrono::NaiveDate;
use uuid::{self, Uuid};
use parse::*;
use unit::*;
#[derive(Debug, Clone, PartialEq)]
@ -220,26 +218,6 @@ impl Ingredient {
self.amt.measure_type(),
);
}
pub fn parse(s: &str) -> Result<Ingredient, String> {
Ok(match ingredient(abortable_parser::StrIter::new(s)) {
abortable_parser::Result::Complete(_, ing) => ing,
abortable_parser::Result::Abort(e) | abortable_parser::Result::Fail(e) => {
return Err(format!("Failed to parse as Ingredient {:?}", e))
}
abortable_parser::Result::Incomplete(_) => {
return Err(format!("Incomplete input: {}", s))
}
})
}
}
impl FromStr for Ingredient {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ingredient::parse(s)
}
}
impl std::fmt::Display for Ingredient {