Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,8 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
///
/// [`File`]s implement `Read`:
///
/// [`read()`]: trait.Read.html#tymethod.read
/// [`std::io`]: ../../std/io/index.html
/// [`File`]: ../fs/struct.File.html
/// [`BufRead`]: trait.BufRead.html
/// [`BufReader`]: struct.BufReader.html
///
/// ```
/// use std::io;
/// # use std::io;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this hidden since it isn't used in visible code

/// use std::io::prelude::*;
/// use std::fs::File;
///
Expand All @@ -449,6 +443,32 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
/// # Ok(())
/// # }
/// ```
///
/// Read from `&str` because [`&[u8]`] implements [`Read`]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulldown doesn't seem to able to parse [`&[u8]`] (@steveklabnik please confirm)

 Documenting std v0.0.0 (file:///home/nodakai/src/rust-HEAD/src/libstd)
WARNING: documentation for this crate may be rendered differently using the new Pulldown renderer.
    See https://github.com/rust-lang/rust/issues/44229 for details.
WARNING: rendering difference in `The `Read` trait allows for reading bytes from a source.`
   --> src/libstd/io/mod.rs:470:0
    /html[0]/body[1]/p[8] Text differs:
        expected: `because`
        found:    `because [`
WARNING: rendering difference in `The `Read` trait allows for reading bytes from a source.`
   --> src/libstd/io/mod.rs:470:0
    /html[0]/body[1]/p[8] Tags differ: expected: `a`, found: `code`
WARNING: rendering difference in `The `Read` trait allows for reading bytes from a source.`
   --> src/libstd/io/mod.rs:470:0
    /html[0]/body[1]/p[8] Text differs:
        expected: `implements`
        found:    `] implements`
WARNING: rendering difference in `The `Read` trait allows for reading bytes from a source.`
   --> src/libstd/io/mod.rs:470:0
    /html[0]/body[1] Unexpected element `p`: found: `<p>[<code>&amp;[u8]</code>]: primitive.slice.html</p>`

///
/// ```
/// # use std::io;
/// use std::io::prelude::*;
///
/// # fn foo() -> io::Result<()> {
/// let mut b = "This string will be read".as_bytes();
/// let mut buffer = [0; 10];
///
/// // read up to 10 bytes
/// b.read(&mut buffer)?;
///
/// // etc... it works exactly as a File does!
/// # Ok(())
/// # }
/// ```
///
/// [`read()`]: trait.Read.html#tymethod.read
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these to the bottom and added &[u8].

/// [`std::io`]: ../../std/io/index.html
/// [`File`]: ../fs/struct.File.html
/// [`BufRead`]: trait.BufRead.html
/// [`BufReader`]: struct.BufReader.html
/// [`&[u8]`]: primitive.slice.html
///
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Read {
/// Pull some bytes from this source into the specified buffer, returning
Expand Down