Rollup merge of #98330 - conradludgate:io-slice-mut-docs, r=Dylan-DPC

update ioslice docs to use shared slices

I noticed that IoSlice docs were taking unnecessary mut slices, when they only accept shared slices
This commit is contained in:
Yuki Okushi 2022-06-21 20:08:17 +09:00 committed by GitHub
commit e5092425eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -1240,8 +1240,8 @@ pub fn new(buf: &'a [u8]) -> IoSlice<'a> {
/// use std::io::IoSlice;
/// use std::ops::Deref;
///
/// let mut data = [1; 8];
/// let mut buf = IoSlice::new(&mut data);
/// let data = [1; 8];
/// let mut buf = IoSlice::new(&data);
///
/// // Mark 3 bytes as read.
/// buf.advance(3);
@ -1435,10 +1435,10 @@ pub trait Write {
/// use std::fs::File;
///
/// fn main() -> std::io::Result<()> {
/// let mut data1 = [1; 8];
/// let mut data2 = [15; 8];
/// let io_slice1 = IoSlice::new(&mut data1);
/// let io_slice2 = IoSlice::new(&mut data2);
/// let data1 = [1; 8];
/// let data2 = [15; 8];
/// let io_slice1 = IoSlice::new(&data1);
/// let io_slice2 = IoSlice::new(&data2);
///
/// let mut buffer = File::create("foo.txt")?;
///

View file

@ -583,8 +583,8 @@ pub fn truncated(&self) -> bool {
/// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]);
/// ancillary.add_fds(&[sock.as_raw_fd()][..]);
///
/// let mut buf = [1; 8];
/// let mut bufs = &mut [IoSlice::new(&mut buf[..])][..];
/// let buf = [1; 8];
/// let mut bufs = &mut [IoSlice::new(&buf[..])][..];
/// sock.send_vectored_with_ancillary(bufs, &mut ancillary)?;
/// Ok(())
/// }