mirror of
https://github.com/rust-lang/rust
synced 2024-09-19 16:32:34 +00:00
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:
commit
e5092425eb
|
@ -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")?;
|
||||
///
|
||||
|
|
|
@ -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(())
|
||||
/// }
|
||||
|
|
Loading…
Reference in a new issue