浏览代码

[All] Fix clippy warnings "expression borrows a reference"

Signed-off-by: Slava Barinov <rayslava@gmail.com>
Slava Barinov 4 年之前
父节点
当前提交
4769278329
共有 5 个文件被更改,包括 9 次插入9 次删除
  1. 2 2
      src/categories.rs
  2. 1 1
      src/convert.rs
  3. 1 1
      src/main.rs
  4. 1 1
      src/receipt.rs
  5. 4 4
      src/telegram.rs

+ 2 - 2
src/categories.rs

@@ -88,7 +88,7 @@ pub fn get_category_from_tg(
     ctx: &UpdateWithCx<AutoSend<Bot>, Message>,
 ) -> String {
     if bot_is_running() {
-        let future = async move { input_category_from_tg(item, &storage, &accounts, &ctx).await };
+        let future = async move { input_category_from_tg(item, storage, accounts, ctx).await };
         if let Ok(handle) = Handle::try_current() {
             tokio::task::block_in_place(move || handle.block_on(future))
         } else {
@@ -115,7 +115,7 @@ pub fn get_category(item: &str, storage: &mut CatStats, accounts: &[String]) ->
         if cat.is_empty() {
             topcat
         } else {
-            assign_category(&item, &cat, storage);
+            assign_category(item, &cat, storage);
             cat
         }
     } else {

+ 1 - 1
src/convert.rs

@@ -115,5 +115,5 @@ where
         &user.accounts,
         categorizer,
     );
-    gen_trans(&acc, purchase.date(), purchase.total_sum(), memo, splits)
+    gen_trans(acc, purchase.date(), purchase.total_sum(), memo, splits)
 }

+ 1 - 1
src/main.rs

@@ -78,7 +78,7 @@ fn main() {
 
     if let Some(filename) = &args.filename {
         let cat = &|item: &str, stats: &mut categories::CatStats, acc: &[String]| -> String {
-            categories::get_category(&item, stats, acc)
+            categories::get_category(item, stats, acc)
         };
         let t = convert::convert(filename, &args.memo, &mut user, &acc, &cat).unwrap();
         print!("{}", acc.to_string());

+ 1 - 1
src/receipt.rs

@@ -90,7 +90,7 @@ struct Input {
 
 pub fn parse_purchase(line: &str) -> Purchase {
     // TODO: Check if several receipts are possible
-    let receipt: Vec<Input> = serde_json::from_str(&line).unwrap();
+    let receipt: Vec<Input> = serde_json::from_str(line).unwrap();
     Purchase {
         sum: receipt[0].query.sum,
         date: receipt[0].query.date,

+ 4 - 4
src/telegram.rs

@@ -85,9 +85,9 @@ async fn convert_file(
     log::info!("Converting file into {}", filepath);
     let mut file = File::create(&filepath).await?;
     log::info!("Got file");
-    for i in non_cat_items(&jsonfile, &user) {
+    for i in non_cat_items(jsonfile, user) {
         log::info!("Message about {}", i);
-        let newcat = input_category_from_tg(&i, &user.catmap, &user.accounts, &ctx).await;
+        let newcat = input_category_from_tg(&i, &user.catmap, &user.accounts, ctx).await;
         ctx.answer(format!("{} is set to {}", i, newcat))
             .await
             .unwrap();
@@ -98,7 +98,7 @@ async fn convert_file(
         .build();
 
     let cat = &|item: &str, stats: &mut CatStats, accounts: &[String]| -> String {
-        get_category_from_tg(&item, stats, accounts, &ctx)
+        get_category_from_tg(item, stats, accounts, ctx)
     };
     let t = convert(jsonfile, "Test", user, &acc, cat)?;
     file.write(acc.to_string().as_bytes()).await?;
@@ -214,7 +214,7 @@ async fn handle_message(
             if let MessageKind::Common(msg) = &update.kind {
                 if let MediaKind::Document(doc) = &msg.media_kind {
                     if let Ok(newfile) =
-                        download_file(&cx.requester.inner(), &doc.document.file_id).await
+                        download_file(cx.requester.inner(), &doc.document.file_id).await
                     {
                         cx.answer(format!("File received: {:} ", newfile)).await?;
                         if let Some(tguser) = cx.update.from() {