fix clippy

Signed-off-by: Yuchen Liang <yuchen@neon.tech>
This commit is contained in:
Yuchen Liang
2024-10-09 12:32:52 -04:00
parent 8f9679ce95
commit 84b0902e6a
3 changed files with 4 additions and 2 deletions

View File

@@ -35,6 +35,7 @@ impl<A: Alignment> AlignedBuffer<A> {
#[inline]
fn as_ptr(&self) -> *const u8 {
// SAFETY: `self.range.start` is guaranteed to be within [0, self.len()).
unsafe { self.raw.as_ptr().add(self.range.start) }
}
@@ -93,6 +94,7 @@ impl<A: Alignment> PartialEq<[u8]> for AlignedBuffer<A> {
}
}
/// SAFETY: the underlying buffer references a stable memory region.
unsafe impl<A: Alignment> tokio_epoll_uring::IoBuf for AlignedBuffer<A> {
fn stable_ptr(&self) -> *const u8 {
self.as_ptr()

View File

@@ -38,7 +38,7 @@ impl<const A: usize> AlignedBufferMut<ConstAlign<A>> {
use bytes::BufMut;
let mut buf = Self::with_capacity(capacity);
buf.put_bytes(0, capacity);
// `put_bytes` filled the entire buffer.
// SAFETY: `put_bytes` filled the entire buffer.
unsafe { buf.set_len(capacity) };
buf
}

View File

@@ -35,6 +35,6 @@ impl<'a, const N: usize, A: Alignment> DerefMut for AlignedSlice<'a, N, A> {
impl<'a, const N: usize, A: Alignment> AsRef<[u8; N]> for AlignedSlice<'a, N, A> {
fn as_ref(&self) -> &[u8; N] {
&self.buf
self.buf
}
}