//! to read the line and print it, so we use `()`.
//!
//! [result]: type.Result.html
-//! [try]: macro.try!.html
+//! [try]: ../macro.try!.html
+//!
+//! ## Platform-specific behavior
+//!
+//! Many I/O functions throughout the standard library are documented to indicate
+//! what various library or syscalls they are delegated to. This is done to help
+//! applications both understand what's happening under the hood as well as investigate
+//! any possibly unclear semantics. Note, however, that this is informative, not a binding
+//! contract. The implementation of many of these functions are subject to change over
+//! time and may call fewer or more syscalls/library functions.
#![stable(feature = "rust1", since = "1.0.0")]
use string::String;
use str;
use vec::Vec;
+use memchr;
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::buffered::{BufReader, BufWriter, LineWriter};
/// 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
/// explicitly be called. The [`write!`][write] macro should be favored to
/// invoke this method instead.
///
- /// [formatargs]: ../std/macro.format_args!.html
- /// [write]: ../std/macro.write!.html
+ /// [formatargs]: ../macro.format_args!.html
+ /// [write]: ../macro.write!.html
///
/// This function internally uses the [`write_all`][writeall] method on
/// this trait and hence will continuously write data so long as no errors
///
/// [`File`][file]s implement `Seek`:
///
-/// [file]: ../std/fs/struct.File.html
+/// [file]: ../fs/struct.File.html
///
/// ```
/// use std::io;
/// Set the offset to the size of this object plus the specified number of
/// bytes.
///
- /// It is possible to seek beyond the end of an object, but is an error to
+ /// It is possible to seek beyond the end of an object, but it's an error to
/// seek before byte 0.
#[stable(feature = "rust1", since = "1.0.0")]
End(i64),
/// Set the offset to the current position plus the specified number of
/// bytes.
///
- /// It is possible to seek beyond the end of an object, but is an error to
+ /// It is possible to seek beyond the end of an object, but it's an error to
/// seek before byte 0.
#[stable(feature = "rust1", since = "1.0.0")]
Current(i64),
Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
Err(e) => return Err(e)
};
- match available.iter().position(|x| *x == delim) {
+ match memchr::memchr(delim, available) {
Some(i) => {
buf.extend_from_slice(&available[..i + 1]);
(true, i + 1)
b.iter(|| {
let mut lr = repeat(1).take(10000000);
let mut vec = Vec::with_capacity(1024);
- super::read_to_end(&mut lr, &mut vec);
+ super::read_to_end(&mut lr, &mut vec)
});
}
}