Skip to content

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

M4: use fixed-size slices in named destination regressions

PerchAnton332688246397
diff --git a/crates/automation/tests/automation.rs b/crates/automation/tests/automation.rs
index 118aebf44..0e75451a8 100644
--- a/crates/automation/tests/automation.rs
+++ b/crates/automation/tests/automation.rs
@@ -824,7 +824,7 @@ fn assert_destination_state(a: &Automation, doc: u64, depth: usize, count: usize
let pairs = node.as_dict().unwrap().get(b"Names").and_then(Object::as_array).unwrap();
assert_eq!(pairs.len(), if deleted { count / 2 * 2 } else { count * 2 });
let expected = (0..count).filter(|i| !deleted || i % 2 == 1);
- for (pair, i) in pairs.chunks_exact(2).zip(expected) {
+ for (pair, i) in pairs.as_chunks::<2>().0.iter().zip(expected) {
assert_eq!(pair[0].as_string().unwrap().to_text(), format!("dest-{i:05}"));
let target = if i % 2 == 0 { pages[0].obj } else { pages.last().unwrap().obj };
assert_eq!(pair[1].as_array().unwrap()[0].as_ref(), Some(target), "destination {i}");
diff --git a/crates/organize/src/tests.rs b/crates/organize/src/tests.rs
index c40347d17..d2720b4f2 100644
--- a/crates/organize/src/tests.rs
+++ b/crates/organize/src/tests.rs
@@ -308,7 +308,7 @@ fn deleting_a_page_keeps_sixty_thousand_named_destinations_usable() {
let pairs = leaf.get(b"Names").unwrap().as_array().unwrap();
assert_eq!(pairs.len(), 60_000, "30,000 surviving name/value pairs");
let page = pages(&reopened).unwrap()[1].obj;
- for (pair, i) in pairs.chunks_exact(2).zip((1..60_000).step_by(2)) {
+ for (pair, i) in pairs.as_chunks::<2>().0.iter().zip((1..60_000).step_by(2)) {
assert_eq!(pair[0].as_string().unwrap().to_text(), format!("dest-{i:05}"));
assert_eq!(pair[1].as_array().unwrap()[0].as_ref(), Some(page));
}