Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

pdf: right-to-left tests read UTF-16 units with as_chunks (clippy 1.99)

aionggc154b4325b20
diff --git a/crates/pdf/src/rtl_tests.rs b/crates/pdf/src/rtl_tests.rs
index 37c9865af..53db2ac25 100644
--- a/crates/pdf/src/rtl_tests.rs
+++ b/crates/pdf/src/rtl_tests.rs
@@ -58,7 +58,7 @@ fn actual_texts(bytes: &[u8]) -> Vec<String> {
let Object::Dict(props) = op.1 else { continue };
let props: &Dict<'_> = props;
let Some(s) = props.get::<hayro_syntax::object::String>(b"ActualText") else { continue };
- let units: Vec<u16> = s.as_bytes().chunks_exact(2).map(|b| u16::from_be_bytes([b[0], b[1]])).collect();
+ let units: Vec<u16> = s.as_bytes().as_chunks::<2>().0.iter().map(|&b| u16::from_be_bytes(b)).collect();
let text = String::from_utf16(&units).expect("UTF-16");
out.push(text.trim_start_matches('\u{FEFF}').to_string());
}