From 596f18201c7863d8b02fe6fa1872cf3ba2b6b381 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 11 Feb 2019 19:31:37 -0800 Subject: impl Deref/DerefMut for IoVec types Returning &'a mut [u8] was unsound, and we may as well just have them directly deref to their slices to make it easier to work with them. --- src/libstd/sys/unix/io.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstd/sys/unix') diff --git a/src/libstd/sys/unix/io.rs b/src/libstd/sys/unix/io.rs index 69b2db82ea3..65e4c6e0577 100644 --- a/src/libstd/sys/unix/io.rs +++ b/src/libstd/sys/unix/io.rs @@ -21,7 +21,7 @@ impl<'a> IoVec<'a> { } #[inline] - pub fn as_slice(&self) -> &'a [u8] { + pub fn as_slice(&self) -> &[u8] { unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) } @@ -46,14 +46,14 @@ impl<'a> IoVecMut<'a> { } #[inline] - pub fn as_slice(&self) -> &'a [u8] { + pub fn as_slice(&self) -> &[u8] { unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) } } #[inline] - pub fn as_mut_slice(&mut self) -> &'a mut [u8] { + pub fn as_mut_slice(&mut self) -> &mut [u8] { unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) } -- cgit 1.4.1-3-g733a5