File tree Expand file tree Collapse file tree 2 files changed +30
-13
lines changed
Expand file tree Collapse file tree 2 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -768,45 +768,62 @@ The base must be 10, and the exponent must be an integer."#
768768 let examples = vec ! [
769769 Numeric :: Scientific ( Quantity {
770770 mantissa: Decimal {
771- number: 10 ,
772- precision: 1 ,
771+ number: 84 ,
772+ precision: 0 ,
773773 } ,
774774 uncertainty: None ,
775775 magnitude: None ,
776776 symbol: "kg" ,
777777 } ) ,
778778 Numeric :: Scientific ( Quantity {
779779 mantissa: Decimal {
780- number: 50 ,
781- precision: 0 ,
780+ number: 30 ,
781+ precision: 1 ,
782782 } ,
783783 uncertainty: None ,
784- magnitude: None ,
785- symbol: "Hz " ,
784+ magnitude: Some ( 8 ) ,
785+ symbol: "m/s " ,
786786 } ) ,
787787 Numeric :: Scientific ( Quantity {
788788 mantissa: Decimal {
789- number: 25 ,
789+ number: 16 ,
790790 precision: 0 ,
791791 } ,
792- uncertainty: None ,
792+ uncertainty: Some ( Decimal {
793+ number: 15 ,
794+ precision: 1 ,
795+ } ) ,
793796 magnitude: None ,
794797 symbol: "°C" ,
795798 } ) ,
799+ Numeric :: Scientific ( Quantity {
800+ mantissa: Decimal {
801+ number: 3126 ,
802+ precision: 1 ,
803+ } ,
804+ uncertainty: None ,
805+ magnitude: None ,
806+ symbol: "μs" ,
807+ } ) ,
796808 ] ;
797809
798810 (
799811 "Invalid character in quantity units" . to_string ( ) ,
800812 format ! (
801813 r#"
802814Symbols used to denote units can contain:
815+
803816 Letters 'A'..'z' {}
817+ Rates '/': {}
804818 Degrees '°': {}
805- And other valid characters.
819+ SI prefixes 'μ': {}
806820
807- Hyphens, underscores, and spaces are not valid in unit symbols."# ,
821+ Hyphens, underscores, spaces, or subscripts are not valid in unit symbols.
822+ "# ,
808823 examples[ 0 ] . present( renderer) ,
809- examples[ 2 ] . present( renderer)
824+ examples[ 1 ] . present( renderer) ,
825+ examples[ 2 ] . present( renderer) ,
826+ examples[ 3 ] . present( renderer)
810827 )
811828 . trim_ascii ( )
812829 . to_string ( ) ,
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ impl Present for Quantity<'_> {
155155
156156 // Add uncertainty if present
157157 if let Some ( uncertainty) = & self . uncertainty {
158- result. push_str ( & renderer. style ( crate :: formatting:: Syntax :: Operator , " ± " ) ) ;
158+ result. push_str ( & renderer. style ( crate :: formatting:: Syntax :: Numeric , " ± " ) ) ;
159159 result. push_str ( & renderer. style (
160160 crate :: formatting:: Syntax :: Numeric ,
161161 & format ! ( "{}" , uncertainty) ,
@@ -164,7 +164,7 @@ impl Present for Quantity<'_> {
164164
165165 // Add magnitude if present
166166 if let Some ( magnitude) = & self . magnitude {
167- result. push_str ( & renderer. style ( crate :: formatting:: Syntax :: Operator , " × " ) ) ;
167+ result. push_str ( & renderer. style ( crate :: formatting:: Syntax :: Numeric , " × " ) ) ;
168168 result. push_str ( & renderer. style ( crate :: formatting:: Syntax :: Numeric , "10" ) ) ;
169169 result. push_str ( & renderer. style (
170170 crate :: formatting:: Syntax :: Numeric ,
You can’t perform that action at this time.
0 commit comments