File tree 1 file changed +3
-8
lines changed
1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -74,14 +74,9 @@ impl Buffer {
74
74
/// Returns the offset, in bytes, of `Self::ptr` to `Self::data`
75
75
///
76
76
/// self.ptr and self.data can be different after slicing or advancing the buffer.
77
- ///
78
- /// # Safety
79
- ///
80
- /// This function is unsafe as it uses unsafe function `offset_from`. Under certain
81
- /// conditions, this function can cause undefined behavior. See the documentation of
82
- /// `offset_from` for more information.
83
- pub unsafe fn ptr_offset ( & self ) -> usize {
84
- self . ptr . offset_from ( self . data . ptr ( ) . as_ptr ( ) ) as usize
77
+ pub fn ptr_offset ( & self ) -> usize {
78
+ // Safety: `ptr` is always in bounds of `data`.
79
+ unsafe { self . ptr . offset_from ( self . data . ptr ( ) . as_ptr ( ) ) as usize }
85
80
}
86
81
87
82
/// Returns the pointer to the start of the buffer without the offset.
You can’t perform that action at this time.
0 commit comments