-
Notifications
You must be signed in to change notification settings - Fork 13.4k
docs: Small clarification on the usage of read_to_string and read_to_end trait methods #142102
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
base: master
Are you sure you want to change the base?
docs: Small clarification on the usage of read_to_string and read_to_end trait methods #142102
Conversation
…to_end` trait methods.
|
This is follow up work on #141935. If possible, reassign to @tgross35. A mistake was made in the previous PR. I attempted a rebase and one thing led to another and the branch became a mess, so I killed the branch. That autoclosed the old PR, so I opened a new one with changes more in line with what Trevor asked. Sorry, but I hope this PR is more like what is expected in this project. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
/// `cat <file> | <my_rust_program>` will correctly terminate with an `EOF` upon closure of cat. | ||
/// Reading user input or running programs that remain open indefinitely will never terminate | ||
/// the stream with `EOF` (e.g. `yes "Data" | pv | <my_rust_program`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two tiny requests:
cat <file> | <my_rust_program
->cat file | my-rust-program
, since those are totally valid binary names they don't need the<>
. (kebab case is slightly more common for binaries)yes | my-rust-program
same as above, and I don't thinkData
orpv
are relevant to the output here are they?
/// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to add [`read`]: Read::read
after this section for the link to go through. Also, looks like there's an extra newline at the end here
I'll let you do this yourself for the experience :) you can request reviews by posting a comment, see rustbot's guidelines:
|
Also it looks like you accidentally picked up a submodule change here. There's about 1000 different ways to fix this but if you need a suggestion, I would do something like this: # Reset to the point where your branch forked from `master`. The reset will get rid
# of your commit and mark all of the files as staged
git reset "$(git merge-base HEAD master)"
# Add the thing you care about
git add library/std
# Get ride of the unintentional changes
git restore src/doc
# Re-commit the files (now only what you care about) using 🪄 magic 🪄 to
# reuse the commit message you have now
git commit -C HEAD@{1}
# Update this PR
git push --force-with-lease Also, you can always check exactly what your PR will look like before pushing with (happy to help with git stuff if you have further questions) |
Small clarification on the usage of read_to_string and read_to_end trait methods. The goal is to make it clear that these trait methods will become locked up if attempting to read to the end of stdin (which is a bit non-sensical unless the other end closes the pipe).
Fixes: #141714