diff options
author | Teddy Wing | 2019-11-02 00:59:37 +0100 |
---|---|---|
committer | Teddy Wing | 2019-11-02 00:59:37 +0100 |
commit | 4edf6b9525521d65edfc9faa4097ffb8b114799f (patch) | |
tree | 0636f366d7f2ba6c43e8cdeaa5fe5b5640e7e328 /src/lib.rs | |
parent | 92f8f57b76b32c3d3e52d4b61dcdf25969f47ab7 (diff) | |
download | pdf-urls-4edf6b9525521d65edfc9faa4097ffb8b114799f.tar.bz2 |
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.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -13,7 +13,7 @@ pub fn get_urls_from_pdf<P: AsRef<Path>>(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<P: AsRef<Path>>(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(()), + _ => (), } } |