Fix parsing of ingredients with addendum but no unit

Where an ingredient has no unit (for example, 2 eggs), the parser was
interpreting `{eggs, 2, large}` as "2, large of eggs", instead of as
"2 eggs (large)".
This commit is contained in:
Ben Bridle 2022-09-15 11:50:53 +12:00
parent 6eee110291
commit 3999fca9e6
1 changed files with 6 additions and 0 deletions

View File

@ -102,6 +102,11 @@ fn capture(chars: &[char]) -> Option<(Ingredient, usize)> {
unit = Some(String::new());
break;
}
Some(&',') => {
i += 1;
addendum = Some(String::new());
break;
}
Some(&'}') => {
i += 1;
break;
@ -115,6 +120,7 @@ fn capture(chars: &[char]) -> Option<(Ingredient, usize)> {
}
// Unit
if let Some(ref mut unit) = unit {
loop {
match chars.get(i) {