Skip to content

Commit 5ffdada

Browse files
committed
Support &mut [Event] epoll buffers
Signed-off-by: Alex Saveau <[email protected]>
1 parent db893ae commit 5ffdada

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/event/epoll.rs

+13
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,19 @@ mod buf {
480480
}
481481
}
482482

483+
impl<'a> EventBuffer for &'a mut [Event] {
484+
type Out = &'a mut [Event];
485+
486+
fn convert(&mut self) -> &mut [MaybeUninit<Event>] {
487+
// SAFETY: we (and the kernel) never uninitialize any values
488+
unsafe { core::mem::transmute::<&mut [Event], &mut [MaybeUninit<Event>]>(self) }
489+
}
490+
491+
unsafe fn filled(self, count: usize) -> Self::Out {
492+
&mut self[..count]
493+
}
494+
}
495+
483496
impl<'a> EventBuffer for &'a mut [MaybeUninit<Event>] {
484497
type Out = &'a mut [Event];
485498

0 commit comments

Comments
 (0)