From aa9abbbab67c6344d382a964b3c451e0bf212efe Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 12 Sep 2018 11:12:12 -0700 Subject: fix rust in-line tests, and parse_line takes ref Forgot to run tests before pushing... thanks CI! --- rust/src/api_helpers.rs | 10 +++++----- rust/src/bin/fatcat-export.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'rust') diff --git a/rust/src/api_helpers.rs b/rust/src/api_helpers.rs index 1df42622..47c03e58 100644 --- a/rust/src/api_helpers.rs +++ b/rust/src/api_helpers.rs @@ -90,11 +90,11 @@ fn test_expand_flags() { creators: true } ); - assert!(ExpandFlags::from_str("").files == false); - assert!(ExpandFlags::from_str("files").files == true); - assert!(ExpandFlags::from_str("something,,files").files == true); - assert!(ExpandFlags::from_str("file").files == false); - let all = ExpandFlags::from_str("files,container,other_thing,releases,creators"); + assert!(ExpandFlags::from_str("").unwrap().files == false); + assert!(ExpandFlags::from_str("files").unwrap().files == true); + assert!(ExpandFlags::from_str("something,,files").unwrap().files == true); + assert!(ExpandFlags::from_str("file").unwrap().files == false); + let all = ExpandFlags::from_str("files,container,other_thing,releases,creators").unwrap(); assert!( all == ExpandFlags { files: true, diff --git a/rust/src/bin/fatcat-export.rs b/rust/src/bin/fatcat-export.rs index 1af321ba..8ab3ef4a 100644 --- a/rust/src/bin/fatcat-export.rs +++ b/rust/src/bin/fatcat-export.rs @@ -114,7 +114,7 @@ fn loop_printer(output_receiver: channel::Receiver, done_sender: channel Ok(()) } -fn parse_line(s: String) -> Result { +fn parse_line(s: &str) -> Result { let fields: Vec = s.split("\t").map(|v| v.to_string()).collect(); if fields.len() != 3 { bail!("Invalid input line"); @@ -187,7 +187,7 @@ pub fn do_export(num_workers: usize, expand: Option, entity_type: E let mut count = 0; for line in buf_input.lines() { let line = line?; - let row = parse_line(line)?; + let row = parse_line(&line)?; match (row.rev_id, row.redirect_id, redirects) { (None, _, _) => (), (Some(_), Some(_), false) => (), -- cgit v1.2.3