From 113252e7852795ae997c773c6c26878081acb31d Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Mon, 9 Sep 2024 11:05:15 -0500 Subject: [PATCH] Ensure BytesIter is an unsafe trait. Closes #104. Part of fixes to addrss #100. --- lexical-util/src/iterator.rs | 2 +- lexical-util/src/noskip.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lexical-util/src/iterator.rs b/lexical-util/src/iterator.rs index 149ab92e..cb4b8adc 100644 --- a/lexical-util/src/iterator.rs +++ b/lexical-util/src/iterator.rs @@ -20,7 +20,7 @@ pub use crate::skip::{AsBytes, Bytes}; /// A default implementation is provided for slice iterators. /// This trait **should never** return `null` from `as_ptr`, or be /// implemented for non-contiguous data. -pub trait BytesIter<'a>: Iterator { +pub unsafe trait BytesIter<'a>: Iterator { /// Determine if each yielded value is adjacent in memory. const IS_CONTIGUOUS: bool; diff --git a/lexical-util/src/noskip.rs b/lexical-util/src/noskip.rs index 8abd9137..8c93557f 100644 --- a/lexical-util/src/noskip.rs +++ b/lexical-util/src/noskip.rs @@ -232,7 +232,7 @@ pub struct BytesIterator<'a: 'b, 'b, const __: u128> { byte: &'b mut Bytes<'a, __>, } -impl<'a: 'b, 'b, const __: u128> BytesIter<'a> for BytesIterator<'a, 'b, __> { +unsafe impl<'a: 'b, 'b, const __: u128> BytesIter<'a> for BytesIterator<'a, 'b, __> { const IS_CONTIGUOUS: bool = Bytes::<'a, __>::IS_CONTIGUOUS; #[inline(always)]