jmelesky 7 年之前
父節點
當前提交
77e5279a72
共有 1 個文件被更改,包括 9 次插入3 次删除
  1. 9 3
      src/main.rs

+ 9 - 3
src/main.rs

@@ -23,9 +23,15 @@ fn scrape_feats(url: &str) {
             header = false;
         } else {
             let mut tds = node.find(Name("td"));
-            let name = tds.next().unwrap().text();
-            let prereqs = tds.next().unwrap().text();
-            let benefit = tds.next().unwrap().text();
+            let name_raw = tds.next().unwrap().text();
+            let prereqs_raw = tds.next().unwrap().text();
+            let benefit_raw = tds.next().unwrap().text();
+
+            // extra variables because '....unwrap().text().trim()' complains
+            // about lifetime of borrowd value
+            let name = name_raw.trim();
+            let prereqs = prereqs_raw.trim();
+            let benefit = benefit_raw.trim();
 
             println!("|{}|{}|{}|", name, prereqs, benefit);
         }