use str;
use vec::Vec;
+#[stable(feature = "rust1", since = "1.0.0")]
pub use self::buffered::{BufReader, BufWriter, LineWriter};
+#[stable(feature = "rust1", since = "1.0.0")]
pub use self::buffered::IntoInnerError;
+#[stable(feature = "rust1", since = "1.0.0")]
pub use self::cursor::Cursor;
+#[stable(feature = "rust1", since = "1.0.0")]
pub use self::error::{Result, Error, ErrorKind};
+#[stable(feature = "rust1", since = "1.0.0")]
pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat};
+#[stable(feature = "rust1", since = "1.0.0")]
pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr};
+#[stable(feature = "rust1", since = "1.0.0")]
pub use self::stdio::{StdoutLock, StderrLock, StdinLock};
+#[unstable(feature = "libstd_io_internals", issue = "0")]
#[doc(no_inline, hidden)]
pub use self::stdio::{set_panic, set_print};
/// will continue.
///
/// If this function encounters an "end of file" before completely filling
- /// the buffer, it returns an error of the kind `ErrorKind::UnexpectedEOF`.
+ /// the buffer, it returns an error of the kind `ErrorKind::UnexpectedEof`.
/// The contents of `buf` are unspecified in this case.
///
/// If any other read error is encountered then this function immediately
/// [file]: ../std/fs/struct.File.html
///
/// ```
- /// #![feature(read_exact)]
/// use std::io;
/// use std::io::prelude::*;
/// use std::fs::File;
/// # Ok(())
/// # }
/// ```
- #[unstable(feature = "read_exact", reason = "recently added", issue = "27585")]
+ #[stable(feature = "read_exact", since = "1.6.0")]
fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> {
while !buf.is_empty() {
match self.read(buf) {
}
}
if !buf.is_empty() {
- Err(Error::new(ErrorKind::UnexpectedEOF,
+ Err(Error::new(ErrorKind::UnexpectedEof,
"failed to fill whole buffer"))
} else {
Ok(())
of where errors happen is currently \
unclear and may change",
issue = "27802")]
+ #[rustc_deprecated(reason = "error handling semantics unclear and \
+ don't seem to have an ergonomic resolution",
+ since = "1.6.0")]
+ #[allow(deprecated)]
fn tee<W: Write>(self, out: W) -> Tee<Self, W> where Self: Sized {
Tee { reader: self, writer: out }
}
of where errors happen is currently \
unclear and may change",
issue = "27802")]
+ #[rustc_deprecated(reason = "error handling semantics unclear and \
+ don't seem to have an ergonomic resolution",
+ since = "1.6.0")]
+ #[allow(deprecated)]
fn broadcast<W: Write>(self, other: W) -> Broadcast<Self, W>
where Self: Sized
{
};
match available.iter().position(|x| *x == delim) {
Some(i) => {
- buf.push_all(&available[..i + 1]);
+ buf.extend_from_slice(&available[..i + 1]);
(true, i + 1)
}
None => {
- buf.push_all(available);
+ buf.extend_from_slice(available);
(false, available.len())
}
}
/// [broadcast]: trait.Write.html#method.broadcast
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast",
issue = "27802")]
+#[rustc_deprecated(reason = "error handling semantics unclear and \
+ don't seem to have an ergonomic resolution",
+ since = "1.6.0")]
pub struct Broadcast<T, U> {
first: T,
second: U,
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast",
issue = "27802")]
+#[rustc_deprecated(reason = "error handling semantics unclear and \
+ don't seem to have an ergonomic resolution",
+ since = "1.6.0")]
+#[allow(deprecated)]
impl<T: Write, U: Write> Write for Broadcast<T, U> {
fn write(&mut self, data: &[u8]) -> Result<usize> {
let n = try!(self.first.write(data));
limit: u64,
}
-#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Take<T> {
/// Returns the number of bytes that can be read before this instance will
/// return EOF.
/// [tee]: trait.Read.html#method.tee
#[unstable(feature = "io", reason = "awaiting stability of Read::tee",
issue = "27802")]
+#[rustc_deprecated(reason = "error handling semantics unclear and \
+ don't seem to have an ergonomic resolution",
+ since = "1.6.0")]
pub struct Tee<R, W> {
reader: R,
writer: W,
#[unstable(feature = "io", reason = "awaiting stability of Read::tee",
issue = "27802")]
+#[rustc_deprecated(reason = "error handling semantics unclear and \
+ don't seem to have an ergonomic resolution",
+ since = "1.6.0")]
+#[allow(deprecated)]
impl<R: Read, W: Write> Read for Tee<R, W> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
let n = try!(self.reader.read(buf));
let mut c = Cursor::new(&b""[..]);
assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
- io::ErrorKind::UnexpectedEOF);
+ io::ErrorKind::UnexpectedEof);
let mut c = Cursor::new(&b"123"[..]).chain(Cursor::new(&b"456789"[..]));
c.read_exact(&mut buf).unwrap();
c.read_exact(&mut buf).unwrap();
assert_eq!(&buf, b"5678");
assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
- io::ErrorKind::UnexpectedEOF);
+ io::ErrorKind::UnexpectedEof);
}
#[test]
let mut c = &b""[..];
assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
- io::ErrorKind::UnexpectedEOF);
+ io::ErrorKind::UnexpectedEof);
let mut c = &b"123"[..];
assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
- io::ErrorKind::UnexpectedEOF);
+ io::ErrorKind::UnexpectedEof);
// make sure the optimized (early returning) method is being used
assert_eq!(&buf, &[0; 4]);