From 6a54cec9ca046509500d1fd2fd8d8e90b0bb1829 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Fri, 17 Jan 2025 19:28:45 +0000 Subject: [PATCH] [IFT] add comment to WritableOffset about DIVISOR. --- incremental-font-transfer/src/glyph_keyed.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/incremental-font-transfer/src/glyph_keyed.rs b/incremental-font-transfer/src/glyph_keyed.rs index fd3adb2d5..113819a9c 100644 --- a/incremental-font-transfer/src/glyph_keyed.rs +++ b/incremental-font-transfer/src/glyph_keyed.rs @@ -259,20 +259,23 @@ fn retained_glyphs_total_size( Ok(total_size) } -trait WritableOffset { +/// Objects with this trait can be written to bytes. +/// +/// The offset value will be divided by DIVISOR prior to conversion to bytes. +trait WritableOffset { fn write_to(self, dest: &mut [u8]); } -impl WritableOffset
for u32 { +impl WritableOffset for u32 { fn write_to(self, dest: &mut [u8]) { - let data: [u8; 4] = (self / DIV as u32).to_raw(); + let data: [u8; 4] = (self / DIVISOR as u32).to_raw(); dest[..4].copy_from_slice(&data); } } -impl WritableOffset
for u16 { +impl WritableOffset for u16 { fn write_to(self, dest: &mut [u8]) { - let data: [u8; 2] = (self / DIV as u16).to_raw(); + let data: [u8; 2] = (self / DIVISOR as u16).to_raw(); dest[..2].copy_from_slice(&data); } }