diff --git a/src/common.rs b/src/common.rs index 6d3138b..e46ded0 100644 --- a/src/common.rs +++ b/src/common.rs @@ -75,7 +75,8 @@ impl<'a> AsciiStr<'a> { #[inline] pub fn check_len(&self, n: usize) -> bool { - unsafe { self.ptr.add(n) <= self.end } + let len = self.end as usize - self.ptr as usize; + n <= len } #[inline]