Skip to content

Commit 47fb4b8

Browse files
committed
Ensure BytesIter is an unsafe trait.
Closes #104 Part of fixes to address #100
1 parent 24a1d6a commit 47fb4b8

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lexical-util/src/iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub use crate::skip::{AsBytes, Bytes};
2020
/// A default implementation is provided for slice iterators.
2121
/// This trait **should never** return `null` from `as_ptr`, or be
2222
/// implemented for non-contiguous data.
23-
pub trait BytesIter<'a>: Iterator<Item = &'a u8> {
23+
pub unsafe trait BytesIter<'a>: Iterator<Item = &'a u8> {
2424
/// Determine if each yielded value is adjacent in memory.
2525
const IS_CONTIGUOUS: bool;
2626

lexical-util/src/noskip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub struct BytesIterator<'a: 'b, 'b, const __: u128> {
232232
byte: &'b mut Bytes<'a, __>,
233233
}
234234

235-
impl<'a: 'b, 'b, const __: u128> BytesIter<'a> for BytesIterator<'a, 'b, __> {
235+
unsafe impl<'a: 'b, 'b, const __: u128> BytesIter<'a> for BytesIterator<'a, 'b, __> {
236236
const IS_CONTIGUOUS: bool = Bytes::<'a, __>::IS_CONTIGUOUS;
237237

238238
#[inline(always)]

lexical-util/src/skip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ macro_rules! skip_iterator_byteiter_base {
721721
/// Create impl ByteIter block for skip iterator.
722722
macro_rules! skip_iterator_byteiter_impl {
723723
($iterator:ident, $mask:ident, $i:ident, $l:ident, $t:ident, $c:ident) => {
724-
impl<'a: 'b, 'b, const FORMAT: u128> BytesIter<'a> for $iterator<'a, 'b, FORMAT> {
724+
unsafe impl<'a: 'b, 'b, const FORMAT: u128> BytesIter<'a> for $iterator<'a, 'b, FORMAT> {
725725
skip_iterator_byteiter_base!(FORMAT, $mask);
726726

727727
/// Peek the next value of the iterator, without consuming it.
@@ -821,7 +821,7 @@ impl<'a: 'b, 'b, const FORMAT: u128> SpecialBytesIterator<'a, 'b, FORMAT> {
821821
is_digit_separator!(FORMAT);
822822
}
823823

824-
impl<'a: 'b, 'b, const FORMAT: u128> BytesIter<'a> for SpecialBytesIterator<'a, 'b, FORMAT> {
824+
unsafe impl<'a: 'b, 'b, const FORMAT: u128> BytesIter<'a> for SpecialBytesIterator<'a, 'b, FORMAT> {
825825
skip_iterator_byteiter_base!(FORMAT, SPECIAL_DIGIT_SEPARATOR);
826826

827827
/// Peek the next value of the iterator, without consuming it.

0 commit comments

Comments
 (0)