@@ -13,8 +13,10 @@ use std::{borrow::Cow, io};
1313pub async fn main ( ) {
1414 let mut requests = json_input_stream ( async_stdin ( ) ) ;
1515
16- let mut app = App :: default ( ) ;
17- app. decimal_comma = uses_decimal_comma ( ) . await ;
16+ let mut app = App {
17+ decimal_comma : uses_decimal_comma ( ) . await ,
18+ ..Default :: default ( )
19+ } ;
1820
1921 while let Some ( result) = requests. next ( ) . await {
2022 match result {
@@ -74,7 +76,7 @@ impl App {
7476 }
7577
7678 pub async fn search ( & mut self , query : & str ) {
77- if let Some ( mut search) = query. strip_prefix ( "=" ) {
79+ if let Some ( mut search) = query. strip_prefix ( '=' ) {
7880 search = search. trim ( ) ;
7981 self . outcome = qcalc ( & mut self . regex , search, self . decimal_comma ) . await ;
8082
@@ -86,7 +88,7 @@ impl App {
8688 . outcome
8789 . clone ( )
8890 . unwrap_or_else ( || [ search, " x = ?" ] . concat ( ) ) ,
89- description : "Math expressions by Qalculate!" . to_owned ( ) ,
91+ description : String :: new ( ) ,
9092 icon : Some ( IconSource :: Name ( Cow :: Borrowed ( "accessories-calculator" ) ) ) ,
9193 ..Default :: default ( )
9294 } ) ,
@@ -137,7 +139,7 @@ async fn qcalc(regex: &mut Regex, expression: &str, decimal_comma: bool) -> Opti
137139 let normalized = regex. replace_all ( line, "" ) ;
138140 let mut normalized = normalized. as_ref ( ) ;
139141
140- if has_issue ( & normalized) {
142+ if has_issue ( normalized) {
141143 return None ;
142144 } else {
143145 if !output. is_empty ( ) {
@@ -153,7 +155,7 @@ async fn qcalc(regex: &mut Regex, expression: &str, decimal_comma: bool) -> Opti
153155 level -= 1 ;
154156
155157 if level == 0 {
156- normalized = & normalized[ byte_pos + 2 ..] . trim_start ( ) ;
158+ normalized = normalized[ byte_pos + 2 ..] . trim_start ( ) ;
157159 break ;
158160 }
159161 }
@@ -169,7 +171,6 @@ async fn qcalc(regex: &mut Regex, expression: &str, decimal_comma: bool) -> Opti
169171 } ;
170172
171173 normalized = normalized[ cut..] . trim_start ( ) ;
172-
173174 if normalized. starts_with ( '(' ) && normalized. ends_with ( ')' ) {
174175 normalized = & normalized[ 1 ..normalized. len ( ) - 1 ] ;
175176 }
@@ -198,5 +199,5 @@ pub async fn uses_decimal_comma() -> bool {
198199 }
199200 }
200201
201- return false ;
202+ false
202203}
0 commit comments