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:
parent
6eee110291
commit
3999fca9e6
|
@ -102,6 +102,11 @@ fn capture(chars: &[char]) -> Option<(Ingredient, usize)> {
|
||||||
unit = Some(String::new());
|
unit = Some(String::new());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Some(&',') => {
|
||||||
|
i += 1;
|
||||||
|
addendum = Some(String::new());
|
||||||
|
break;
|
||||||
|
}
|
||||||
Some(&'}') => {
|
Some(&'}') => {
|
||||||
i += 1;
|
i += 1;
|
||||||
break;
|
break;
|
||||||
|
@ -115,6 +120,7 @@ fn capture(chars: &[char]) -> Option<(Ingredient, usize)> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unit
|
// Unit
|
||||||
|
|
||||||
if let Some(ref mut unit) = unit {
|
if let Some(ref mut unit) = unit {
|
||||||
loop {
|
loop {
|
||||||
match chars.get(i) {
|
match chars.get(i) {
|
||||||
|
|
Loading…
Reference in New Issue