Skip to content

Commit

Permalink
Move BorrowedBuf and BorrowedCursor from std:io to core::io
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillikin committed Nov 8, 2023
1 parent 7adc89b commit c67267c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#![unstable(feature = "read_buf", issue = "78485")]
#![unstable(feature = "core_io", issue = "117693")]

#[cfg(test)]
mod tests;

use crate::fmt::{self, Debug, Formatter};
use crate::io::{Result, Write};
use crate::mem::{self, MaybeUninit};
use crate::{cmp, ptr};

Expand Down Expand Up @@ -303,15 +302,3 @@ impl<'a> BorrowedCursor<'a> {
self.buf.filled += buf.len();
}
}

impl<'a> Write for BorrowedCursor<'a> {
fn write(&mut self, buf: &[u8]) -> Result<usize> {
self.append(buf);
Ok(buf.len())
}

#[inline]
fn flush(&mut self) -> Result<()> {
Ok(())
}
}
File renamed without changes.
6 changes: 6 additions & 0 deletions library/core/src/io/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! Traits, helpers, and type definitions for core I/O functionality.
mod borrowed_buf;

#[unstable(feature = "core_io", issue = "117693")]
pub use self::borrowed_buf::{BorrowedBuf, BorrowedCursor};
2 changes: 2 additions & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ pub mod cell;
pub mod char;
pub mod ffi;
pub mod iter;
#[unstable(feature = "core_io", issue = "117693")]
pub mod io;
pub mod net;
pub mod option;
pub mod panic;
Expand Down
13 changes: 13 additions & 0 deletions library/std/src/io/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,16 @@ impl<A: Allocator> Write for VecDeque<u8, A> {
Ok(())
}
}

#[unstable(feature = "read_buf", issue = "78485")]
impl<'a> io::Write for core::io::BorrowedCursor<'a> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.append(buf);
Ok(buf.len())
}

#[inline]
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
3 changes: 1 addition & 2 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pub use self::{
};

#[unstable(feature = "read_buf", issue = "78485")]
pub use self::readbuf::{BorrowedBuf, BorrowedCursor};
pub use core::io::{BorrowedBuf, BorrowedCursor};
pub(crate) use error::const_io_error;

mod buffered;
Expand All @@ -339,7 +339,6 @@ mod cursor;
mod error;
mod impls;
pub mod prelude;
mod readbuf;
mod stdio;
mod util;

Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
// tidy-alphabetical-start
#![feature(char_internals)]
#![feature(core_intrinsics)]
#![feature(core_io)]
#![feature(duration_constants)]
#![feature(error_generic_member_access)]
#![feature(error_in_core)]
Expand Down

0 comments on commit c67267c

Please sign in to comment.