-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 BufWriter::buffer method #55211
Add BufWriter::buffer method #55211
Conversation
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
@shepmaster Does this PR look reasonable? |
src/libstd/io/buffered.rs
Outdated
/// ``` | ||
#[unstable(feature = "bufreader_buffer", issue = "45323")] | ||
pub fn buffer(&self) -> &[u8] { | ||
&self.buf[..] |
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.
Nit: This can just be &self.buf
.
Could you add a simple test? Looks good otherwise! |
Sorry, I was away at a conference and let this drop off my radar.
You can use |
Of course, I meant |
Is this ready for merging at this point? |
src/libstd/io/buffered.rs
Outdated
/// use std::io::BufWriter; | ||
/// use std::net::TcpStream; | ||
/// | ||
/// let mut buf_writer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); |
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.
This mut
is unneeded for this example, right?
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.
I think most other examples return a result to avoid the unwrap
:
fn main() -> std::io::Result<()> {
let buf_writer = BufWriter::new(TcpStream::connect("127.0.0.1:34254")?);
Check to see what the prevailing pattern is and follow that, please.
src/libstd/io/buffered.rs
Outdated
let b: &[_] = &[5, 6, 7]; | ||
assert_eq!(buf, b); | ||
assert_eq!(buf, [5, 6, 7]); | ||
assert_eq!(*reader.buffer(), []); |
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.
These *
don't seem to be needed — why did you have to add them?
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Looks OK to me — care to hit it with a rebase and force-push and we'll be on our way! |
72fbba0
to
59a0309
Compare
Ping from triage @shepmaster: it looks like the PR has been rebased and is ready for a final review. |
@bors r+ rollup |
📌 Commit 59a0309 has been approved by |
Argh; I forget GH doesn't ping for force pushes — sorry! |
…ster Add BufWriter::buffer method CC rust-lang#45323
Rollup of 16 pull requests Successful merges: - #54906 (Reattach all grandchildren when constructing specialization graph.) - #55182 (Redox: Update to new changes) - #55211 (Add BufWriter::buffer method) - #55507 (Add link to std::mem::size_of to size_of intrinsic documentation) - #55530 (Speed up String::from_utf16) - #55556 (Use `Mmap` to open the rmeta file.) - #55622 (NetBSD: link libstd with librt in addition to libpthread) - #55827 (A few tweaks to iterations/collecting) - #55901 (fix various typos in doc comments) - #55926 (Change sidebar selector to fix compatibility with docs.rs) - #55930 (A handful of hir tweaks) - #55932 (core/char: Speed up `to_digit()` for `radix <= 10`) - #55935 (appveyor: Use VS2017 for all our images) - #55936 (save-analysis: be even more aggressive about ignorning macro-generated defs) - #55948 (submodules: update clippy from d8b4269 to 7e0ddef) - #55956 (add tests for some fixed ICEs)
…ster Add BufWriter::buffer method CC rust-lang#45323
Rollup of 17 pull requests Successful merges: - #55182 (Redox: Update to new changes) - #55211 (Add BufWriter::buffer method) - #55507 (Add link to std::mem::size_of to size_of intrinsic documentation) - #55530 (Speed up String::from_utf16) - #55556 (Use `Mmap` to open the rmeta file.) - #55622 (NetBSD: link libstd with librt in addition to libpthread) - #55750 (Make `NodeId` and `HirLocalId` `newtype_index`) - #55778 (Wrap some query results in `Lrc`.) - #55781 (More precise spans for temps and their drops) - #55785 (Add mem::forget_unsized() for forgetting unsized values) - #55852 (Rewrite `...` as `..=` as a `MachineApplicable` 2018 idiom lint) - #55865 (Unix RwLock: avoid racy access to write_locked) - #55901 (fix various typos in doc comments) - #55926 (Change sidebar selector to fix compatibility with docs.rs) - #55930 (A handful of hir tweaks) - #55932 (core/char: Speed up `to_digit()` for `radix <= 10`) - #55956 (add tests for some fixed ICEs) Failed merges: r? @ghost
CC #45323