We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 380f130 commit dc2347cCopy full SHA for dc2347c
src/iter.rs
@@ -43,12 +43,9 @@ impl<'a> Bytes<'a> {
43
44
#[inline]
45
pub fn peek_ahead(&self, n: usize) -> Option<u8> {
46
- // SAFETY: obtain a potentially OOB pointer that is later compared against the `self.end`
47
- // pointer.
48
- let ptr = self.cursor.wrapping_add(n);
49
- if ptr < self.end {
+ if n < self.len() {
50
// SAFETY: bounds checked pointer dereference is safe
51
- Some(unsafe { *ptr })
+ Some(unsafe { *self.cursor.add(n) })
52
} else {
53
None
54
}
0 commit comments