浏览代码

Refactor line_to_word

Avoid taking ownership if not needed.
Use idiomatic rust.
Blallo 4 年之前
父节点
当前提交
b552804b56
共有 1 个文件被更改,包括 2 次插入5 次删除
  1. 2 5
      src/main.rs

+ 2 - 5
src/main.rs

@@ -47,11 +47,8 @@ impl Iterator for Dictionary {
     }
 }
 
-fn line_to_word(l: String) -> String {
-    let l = unidecode(&l);
-    let l = l.to_lowercase();
-    let l = l.replace("'", "");
-    l
+fn line_to_word(line: &str) -> String {
+    unidecode(&line.to_string()).to_lowercase().replace("'", "")
 }
 
 // filtri {{{