@@ -9,7 +9,7 @@ use crate::parser::{
99 self , BlockKind , Event , IntermediateData , IntermediateRefMode , IntermediateTargetKind ,
1010 Modifiers ,
1111} ;
12- use crate :: quantity:: { Quantity , QuantityValue , ScalableValue , UnitInfo , Value } ;
12+ use crate :: quantity:: { Quantity , QuantityValue , ScalableValue , Value } ;
1313use crate :: span:: Span ;
1414use crate :: text:: Text ;
1515use crate :: { model:: * , Extensions , ParseOptions } ;
@@ -653,14 +653,15 @@ impl<'i> RecipeCollector<'i, '_> {
653653 . unwrap_or ( new_q_loc. span ( ) ) ;
654654
655655 let ( main_label, support_label) = match & e {
656- crate :: quantity:: IncompatibleUnits :: MissingUnit { found } => {
656+ crate :: quantity:: IncompatibleUnits :: MissingUnit { lhs , .. } => {
657657 let m = "value missing unit" ;
658658 let f = "found unit" ;
659- match found {
659+ if * lhs {
660660 // new is mising
661- either:: Either :: Left ( _) => ( label ! ( new, m) , label ! ( old, f) ) ,
661+ ( label ! ( new, m) , label ! ( old, f) )
662+ } else {
662663 // old is missing
663- either :: Either :: Right ( _ ) => ( label ! ( new, f) , label ! ( old, m) ) ,
664+ ( label ! ( new, f) , label ! ( old, m) )
664665 }
665666 }
666667 crate :: quantity:: IncompatibleUnits :: DifferentPhysicalQuantities {
@@ -723,8 +724,8 @@ impl<'i> RecipeCollector<'i, '_> {
723724 if let Some ( ( ref_q, def_q) ) =
724725 & new_igr. quantity . as_ref ( ) . zip ( definition. quantity . as_ref ( ) )
725726 {
726- let ref_is_text = ref_q. value . is_text ( ) ;
727- let def_is_text = def_q. value . is_text ( ) ;
727+ let ref_is_text = ref_q. value ( ) . is_text ( ) ;
728+ let def_is_text = def_q. value ( ) . is_text ( ) ;
728729
729730 if ref_is_text != def_is_text {
730731 let ref_q_loc = located_ingredient. quantity . as_ref ( ) . unwrap ( ) . span ( ) ;
@@ -974,16 +975,16 @@ impl<'i> RecipeCollector<'i, '_> {
974975 let quantity = self . quantity ( q, false ) ;
975976 if self . extensions . contains ( Extensions :: ADVANCED_UNITS ) {
976977 let located_quantity = located_timer. quantity . as_ref ( ) . unwrap ( ) ;
977- if quantity. value . is_text ( ) {
978+ if quantity. value ( ) . is_text ( ) {
978979 self . ctx . error ( error ! (
979- format!( "Timer value is text: {}" , quantity. value) ,
980+ format!( "Timer value is text: {}" , quantity. value( ) ) ,
980981 label!( located_quantity. value. span( ) , "expected a number here" )
981982 ) ) ;
982983 }
983- if let Some ( unit ) = quantity. unit ( ) {
984+ if let Some ( unit_text ) = quantity. unit ( ) {
984985 let unit_span = located_quantity. unit . as_ref ( ) . unwrap ( ) . span ( ) ;
985- match unit . unit_info_or_parse ( self . converter ) {
986- UnitInfo :: Known ( unit) => {
986+ match quantity . unit_info ( self . converter ) {
987+ Some ( unit) => {
987988 if unit. physical_quantity != PhysicalQuantity :: Time {
988989 self . ctx . error ( error ! (
989990 format!( "Timer unit is not time: {unit}" ) ,
@@ -995,8 +996,8 @@ impl<'i> RecipeCollector<'i, '_> {
995996 ) ) ;
996997 }
997998 }
998- UnitInfo :: Unknown => self . ctx . error ( error ! (
999- format!( "Unknown timer unit: {unit }" ) ,
999+ None => self . ctx . error ( error ! (
1000+ format!( "Unknown timer unit: {unit_text }" ) ,
10001001 label!( unit_span, "expected time unit" )
10011002 ) ) ,
10021003 }
@@ -1377,7 +1378,7 @@ fn find_inline_quantity<'a>(
13771378
13781379 fn eat_word < ' a > ( text : & ' a str , i : & mut usize ) -> Option < & ' a str > {
13791380 let s = & text[ * i..] ;
1380- let offset = s. find ( |c : char | c. is_whitespace ( ) ) . or_else ( || {
1381+ let offset = s. find ( |c : char | c. is_whitespace ( ) ) . or ( {
13811382 // if no whitespace until the end if there is anything left
13821383 if !s. is_empty ( ) {
13831384 Some ( s. len ( ) )
@@ -1439,16 +1440,15 @@ fn find_inline_quantity<'a>(
14391440 let Ok ( mut number) = number. parse :: < f64 > ( ) else {
14401441 continue ;
14411442 } ;
1442- let Some ( parsed_unit ) = converter. find_unit ( unit) else {
1443+ if converter. find_unit ( unit) . is_none ( ) {
14431444 continue ;
14441445 } ;
14451446
14461447 if neg {
14471448 number = -number;
14481449 }
14491450
1450- let q =
1451- Quantity :: with_text_and_known_unit ( Value :: from ( number) , unit. to_string ( ) , parsed_unit) ;
1451+ let q = Quantity :: new ( Value :: from ( number) , Some ( unit. to_string ( ) ) ) ;
14521452 return Some ( ( before, q, after) ) ;
14531453 }
14541454
0 commit comments