Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

chore(a11y, fonts): satisfy clippy in the CID width ranges and a test helper

aiongg3e968c8aa24a
diff --git a/crates/a11y/src/tests.rs b/crates/a11y/src/tests.rs
index a24f59edb..ad5747736 100644
--- a/crates/a11y/src/tests.rs
+++ b/crates/a11y/src/tests.rs
@@ -1033,7 +1033,7 @@ fn mark_reads(f: impl FnOnce()) -> usize {
/// Page content nesting `depth` unmarked `BMC` blocks around a marked one, with `ops` operators inside.
fn deeply_nested_page(doc: &mut Document, depth: usize, ops: usize) -> pdfcraft_cos::Dict {
use pdfcraft_cos::{Dict, Stream};
- let mut data = "/Figure << /MCID 0 >> BDC ".repeat(1);
+ let mut data = "/Figure << /MCID 0 >> BDC ".to_string();
data.push_str(&"/X BMC ".repeat(depth));
data.push_str(&"0 0 1 1 re f ".repeat(ops));
data.push_str(&"EMC ".repeat(depth + 1));
diff --git a/crates/fonts/src/pdf.rs b/crates/fonts/src/pdf.rs
index 4a118a07d..3ddd16a9b 100644
--- a/crates/fonts/src/pdf.rs
+++ b/crates/fonts/src/pdf.rs
@@ -714,10 +714,10 @@ impl Metrics {
i += 2;
}
Some(c1) => {
- if let (Some(c1), Some(v)) = (c1.as_f64(), w.get(i + 2).and_then(|x| doc.resolve(x).as_f64())) {
- if ranges.len() < MAX_CMAP_ENTRIES {
- ranges.push((c0, c1 as u32, v));
- }
+ if let (Some(c1), Some(v)) = (c1.as_f64(), w.get(i + 2).and_then(|x| doc.resolve(x).as_f64()))
+ && ranges.len() < MAX_CMAP_ENTRIES
+ {
+ ranges.push((c0, c1 as u32, v));
}
i += 3;
}