aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2019-11-02 00:59:37 +0100
committerTeddy Wing2019-11-02 00:59:37 +0100
commit4edf6b9525521d65edfc9faa4097ffb8b114799f (patch)
tree0636f366d7f2ba6c43e8cdeaa5fe5b5640e7e328 /src
parent92f8f57b76b32c3d3e52d4b61dcdf25969f47ab7 (diff)
downloadpdf-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')
-rw-r--r--src/lib.rs13
1 files changed, 4 insertions, 9 deletions
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<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(()),
+ _ => (),
}
}