Rollup merge of #117694 - jmillikin:core-io-borrowed-buf, r=m-ou-se · rust-lang/rust@b4fa5b7 (original) (raw)

10 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
24 24 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")\]
25 25 #![feature(array_windows)]
26 26 #![feature(cfg_match)]
27 +#![feature(core_io_borrowed_buf)]
27 28 #![feature(if_let_guard)]
28 29 #![feature(let_chains)]
29 30 #![feature(min_specialization)]
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
1 -#![unstable(feature = "read_buf", issue = "78485")]
2 -
3 -#[cfg(test)]
4 -mod tests;
1 +#![unstable(feature = "core_io_borrowed_buf", issue = "117693")]
5 2
6 3 use crate::fmt::{self, Debug, Formatter};
7 -use crate::io::{Result, Write};
8 4 use crate::mem::{self, MaybeUninit};
9 5 use crate::{cmp, ptr};
10 6
@@ -303,16 +299,3 @@ impl<'a> BorrowedCursor<'a> {
303 299 self.buf.filled += buf.len();
304 300 }
305 301 }
306 -
307 -impl<'a> Write for BorrowedCursor<'a> {
308 -fn write(&mut self, buf: &[u8]) -> Result<usize> {
309 -let amt = cmp::min(buf.len(), self.capacity());
310 -self.append(&buf[..amt]);
311 -Ok(amt)
312 -}
313 -
314 -#[inline]
315 -fn flush(&mut self) -> Result<()> {
316 -Ok(())
317 -}
318 -}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1 +//! Traits, helpers, and type definitions for core I/O functionality.
2 +
3 +mod borrowed_buf;
4 +
5 +#[unstable(feature = "core_io_borrowed_buf", issue = "117693")]
6 +pub use self::borrowed_buf::{BorrowedBuf, BorrowedCursor};
Original file line number Diff line number Diff line change
@@ -369,6 +369,8 @@ pub mod async_iter;
369 369 pub mod cell;
370 370 pub mod char;
371 371 pub mod ffi;
372 +#[unstable(feature = "core_io_borrowed_buf", issue = "117693")]
373 +pub mod io;
372 374 pub mod iter;
373 375 pub mod net;
374 376 pub mod option;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1 -use super::BorrowedBuf;
2 -use crate::mem::MaybeUninit;
1 +use core::io::BorrowedBuf;
2 +use core::mem::MaybeUninit;
3 3
4 4 /// Test that BorrowedBuf has the correct numbers when created with new
5 5 #[test]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 +mod borrowed_buf;
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
23 23 #![feature(const_likely)]
24 24 #![feature(const_location_fields)]
25 25 #![feature(core_intrinsics)]
26 +#![feature(core_io_borrowed_buf)]
26 27 #![feature(core_private_bignum)]
27 28 #![feature(core_private_diy_float)]
28 29 #![feature(dec2flt)]
@@ -135,6 +136,7 @@ mod fmt;
135 136 mod future;
136 137 mod hash;
137 138 mod intrinsics;
139 +mod io;
138 140 mod iter;
139 141 mod lazy;
140 142 #[cfg(test)]
Original file line number Diff line number Diff line change
@@ -528,3 +528,17 @@ impl<A: Allocator> Write for VecDeque<u8, A> {
528 528 Ok(())
529 529 }
530 530 }
531 +
532 +#[unstable(feature = "read_buf", issue = "78485")]
533 +impl<'a> io::Write for core::io::BorrowedCursor<'a> {
534 +fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
535 +let amt = cmp::min(buf.len(), self.capacity());
536 +self.append(&buf[..amt]);
537 +Ok(amt)
538 +}
539 +
540 +#[inline]
541 +fn flush(&mut self) -> io::Result<()> {
542 +Ok(())
543 +}
544 +}
Original file line number Diff line number Diff line change
@@ -330,7 +330,7 @@ pub use self::{
330 330 };
331 331
332 332 #[unstable(feature = "read_buf", issue = "78485")]
333 -pub use self::readbuf::{BorrowedBuf, BorrowedCursor};
333 +pub use core::io::{BorrowedBuf, BorrowedCursor};
334 334 pub(crate) use error::const_io_error;
335 335
336 336 mod buffered;
@@ -339,7 +339,6 @@ mod cursor;
339 339 mod error;
340 340 mod impls;
341 341 pub mod prelude;
342 -mod readbuf;
343 342 mod stdio;
344 343 mod util;
345 344
Original file line number Diff line number Diff line change
@@ -310,6 +310,7 @@
310 310 // tidy-alphabetical-start
311 311 #![feature(char_internals)]
312 312 #![feature(core_intrinsics)]
313 +#![feature(core_io_borrowed_buf)]
313 314 #![feature(duration_constants)]
314 315 #![feature(error_generic_member_access)]
315 316 #![feature(error_in_core)]