Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add doc for doing Read from &str #46088

Merged
merged 1 commit into from
Nov 21, 2017
Merged

add doc for doing Read from &str #46088

merged 1 commit into from
Nov 21, 2017

Conversation

vitiral
Copy link
Contributor

@vitiral vitiral commented Nov 18, 2017

This information can be found on stackoverflow but I think it would be beneficial if it was documented in the Read trait itself.

I had an extremely hard time finding this information, and "mocking" a reader with a string is an EXTREMELY common thing (I believe).

@vitiral
Copy link
Contributor Author

vitiral commented Nov 18, 2017

I'm still running x.py locally, but I will make sure to fix anything that's broken

@vitiral vitiral force-pushed the read_doc branch 2 times, most recently from 8998038 to bf483fc Compare November 18, 2017 23:39
Copy link
Contributor Author

@vitiral vitiral left a comment

Choose a reason for hiding this comment

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

some comments

/// ```
/// 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

/// # }
/// ```
///
/// [`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].

@vitiral vitiral force-pushed the read_doc branch 2 times, most recently from 95d4c99 to 44da4a0 Compare November 18, 2017 23:43
@steveklabnik
Copy link
Member

This looks great to me, agree 100%. Thanks so much!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Nov 19, 2017

📌 Commit 44da4a0 has been approved by steveklabnik

@vitiral
Copy link
Contributor Author

vitiral commented Nov 19, 2017

thanks @steveklabnik, no problem!

@kennytm kennytm added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 19, 2017
kennytm added a commit to kennytm/rust that referenced this pull request Nov 20, 2017
add doc for doing `Read` from `&str`

This information can be found on [stackoverflow](https://stackoverflow.com/questions/32674905/pass-string-to-function-taking-read-trait) but I think it would be beneficial if it was documented in the `Read` trait itself.

I had an *extremely* hard time finding this information, and "mocking" a reader with a string is an EXTREMELY common thing (I believe).
bors added a commit that referenced this pull request Nov 20, 2017
Rollup of 9 pull requests

- Successful merges: #46082, #46088, #46092, #46107, #46119, #46121, #46122, #46124, #46128
- Failed merges:
@bors bors merged commit 44da4a0 into rust-lang:master Nov 21, 2017
@@ -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>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants