From 4edf6b9525521d65edfc9faa4097ffb8b114799f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 2 Nov 2019 00:59:37 +0100 Subject: get_urls_from_pdf: Remove `return`s to fix URL output Turns out when I removed the `unwrap`s in 92f8f57b76b32c3d3e52d4b61dcdf25969f47ab7, the `return`s I added to the `match` expressions caused the loops to exit early without iterating over all the objects in the PDF. Remove the `return`s and fix up the expression return types to get URLs printing again. --- src/lib.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 60e2338..c09fe3e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ pub fn get_urls_from_pdf>(path: P) -> Result<()> { let doc = Document::load(path)?; for (_, obj) in doc.objects { - return match obj { + match obj { Object::Dictionary(d) => { for (k, v) in d.iter() { let key = str::from_utf8(&k)?; @@ -25,23 +25,18 @@ pub fn get_urls_from_pdf>(path: P) -> Result<()> { let key = str::from_utf8(&k)?; if key == "URI" { - - return match v { + match v { Object::String(s, _) => { println!("{}", str::from_utf8(s)?); - - Ok(()) }, - _ => Ok(()), + _ => (), } } } } } - - Ok(()) }, - _ => Ok(()), + _ => (), } } -- cgit v1.2.3