1diff --git a/buffered.rs b/buffered.rs 2index 44dd4e9..20ab840 100644 3--- a/buffered.rs 4+++ b/buffered.rs 5@@ -10,13 +10,13 @@ 6 7 //! Buffering wrappers for I/O traits 8 9+use core::prelude::v1::*; 10 use io::prelude::*; 11 12-use cmp; 13-use error; 14-use fmt; 15+use core::cmp; 16+use core::fmt; 17 use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; 18-use memchr; 19+use io::memchr; 20 21 /// The `BufReader` struct adds buffering to any reader. 22 /// 23@@ -46,7 +46,6 @@ use memchr; 24 /// # Ok(()) 25 /// # } 26 /// ``` 27-#[stable(feature = "rust1", since = "1.0.0")] 28 pub struct BufReader<R> { 29 inner: R, 30 buf: Box<[u8]>, 31@@ -69,7 +68,6 @@ impl<R: Read> BufReader<R> { 32 /// # Ok(()) 33 /// # } 34 /// ``` 35- #[stable(feature = "rust1", since = "1.0.0")] 36 pub fn new(inner: R) -> BufReader<R> { 37 BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) 38 } 39@@ -90,7 +88,6 @@ impl<R: Read> BufReader<R> { 40 /// # Ok(()) 41 /// # } 42 /// ``` 43- #[stable(feature = "rust1", since = "1.0.0")] 44 pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> { 45 BufReader { 46 inner: inner, 47@@ -118,7 +115,6 @@ impl<R: Read> BufReader<R> { 48 /// # Ok(()) 49 /// # } 50 /// ``` 51- #[stable(feature = "rust1", since = "1.0.0")] 52 pub fn get_ref(&self) -> &R { &self.inner } 53 54 /// Gets a mutable reference to the underlying reader. 55@@ -139,7 +135,6 @@ impl<R: Read> BufReader<R> { 56 /// # Ok(()) 57 /// # } 58 /// ``` 59- #[stable(feature = "rust1", since = "1.0.0")] 60 pub fn get_mut(&mut self) -> &mut R { &mut self.inner } 61 62 /// Unwraps this `BufReader`, returning the underlying reader. 63@@ -160,11 +155,9 @@ impl<R: Read> BufReader<R> { 64 /// # Ok(()) 65 /// # } 66 /// ``` 67- #[stable(feature = "rust1", since = "1.0.0")] 68 pub fn into_inner(self) -> R { self.inner } 69 } 70 71-#[stable(feature = "rust1", since = "1.0.0")] 72 impl<R: Read> Read for BufReader<R> { 73 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { 74 // If we don't have any buffered data and we're doing a massive read 75@@ -182,7 +175,6 @@ impl<R: Read> Read for BufReader<R> { 76 } 77 } 78 79-#[stable(feature = "rust1", since = "1.0.0")] 80 impl<R: Read> BufRead for BufReader<R> { 81 fn fill_buf(&mut self) -> io::Result<&[u8]> { 82 // If we've reached the end of our internal buffer then we need to fetch 83@@ -199,7 +191,6 @@ impl<R: Read> BufRead for BufReader<R> { 84 } 85 } 86 87-#[stable(feature = "rust1", since = "1.0.0")] 88 impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug { 89 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { 90 fmt.debug_struct("BufReader") 91@@ -209,7 +200,6 @@ impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug { 92 } 93 } 94 95-#[stable(feature = "rust1", since = "1.0.0")] 96 impl<R: Seek> Seek for BufReader<R> { 97 /// Seek to an offset, in bytes, in the underlying reader. 98 /// 99@@ -302,7 +292,6 @@ impl<R: Seek> Seek for BufReader<R> { 100 /// [`Write`]: ../../std/io/trait.Write.html 101 /// [`write`]: ../../std/net/struct.TcpStream.html#method.write 102 /// [`TcpStream`]: ../../std/net/struct.TcpStream.html 103-#[stable(feature = "rust1", since = "1.0.0")] 104 pub struct BufWriter<W: Write> { 105 inner: Option<W>, 106 buf: Vec<u8>, 107@@ -337,7 +326,6 @@ pub struct BufWriter<W: Write> { 108 /// }; 109 /// ``` 110 #[derive(Debug)] 111-#[stable(feature = "rust1", since = "1.0.0")] 112 pub struct IntoInnerError<W>(W, Error); 113 114 impl<W: Write> BufWriter<W> { 115@@ -351,7 +339,6 @@ impl<W: Write> BufWriter<W> { 116 /// 117 /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); 118 /// ``` 119- #[stable(feature = "rust1", since = "1.0.0")] 120 pub fn new(inner: W) -> BufWriter<W> { 121 BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) 122 } 123@@ -369,7 +356,6 @@ impl<W: Write> BufWriter<W> { 124 /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); 125 /// let mut buffer = BufWriter::with_capacity(100, stream); 126 /// ``` 127- #[stable(feature = "rust1", since = "1.0.0")] 128 pub fn with_capacity(cap: usize, inner: W) -> BufWriter<W> { 129 BufWriter { 130 inner: Some(inner), 131@@ -418,7 +404,6 @@ impl<W: Write> BufWriter<W> { 132 /// // we can use reference just like buffer 133 /// let reference = buffer.get_ref(); 134 /// ``` 135- #[stable(feature = "rust1", since = "1.0.0")] 136 pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } 137 138 /// Gets a mutable reference to the underlying writer. 139@@ -436,7 +421,6 @@ impl<W: Write> BufWriter<W> { 140 /// // we can use reference just like buffer 141 /// let reference = buffer.get_mut(); 142 /// ``` 143- #[stable(feature = "rust1", since = "1.0.0")] 144 pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } 145 146 /// Unwraps this `BufWriter`, returning the underlying writer. 147@@ -454,7 +438,6 @@ impl<W: Write> BufWriter<W> { 148 /// // unwrap the TcpStream and flush the buffer 149 /// let stream = buffer.into_inner().unwrap(); 150 /// ``` 151- #[stable(feature = "rust1", since = "1.0.0")] 152 pub fn into_inner(mut self) -> Result<W, IntoInnerError<BufWriter<W>>> { 153 match self.flush_buf() { 154 Err(e) => Err(IntoInnerError(self, e)), 155@@ -463,7 +446,6 @@ impl<W: Write> BufWriter<W> { 156 } 157 } 158 159-#[stable(feature = "rust1", since = "1.0.0")] 160 impl<W: Write> Write for BufWriter<W> { 161 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { 162 if self.buf.len() + buf.len() > self.buf.capacity() { 163@@ -483,7 +465,6 @@ impl<W: Write> Write for BufWriter<W> { 164 } 165 } 166 167-#[stable(feature = "rust1", since = "1.0.0")] 168 impl<W: Write> fmt::Debug for BufWriter<W> where W: fmt::Debug { 169 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { 170 fmt.debug_struct("BufWriter") 171@@ -493,7 +474,6 @@ impl<W: Write> fmt::Debug for BufWriter<W> where W: fmt::Debug { 172 } 173 } 174 175-#[stable(feature = "rust1", since = "1.0.0")] 176 impl<W: Write + Seek> Seek for BufWriter<W> { 177 /// Seek to the offset, in bytes, in the underlying writer. 178 /// 179@@ -503,7 +483,6 @@ impl<W: Write + Seek> Seek for BufWriter<W> { 180 } 181 } 182 183-#[stable(feature = "rust1", since = "1.0.0")] 184 impl<W: Write> Drop for BufWriter<W> { 185 fn drop(&mut self) { 186 if self.inner.is_some() && !self.panicked { 187@@ -542,7 +521,6 @@ impl<W> IntoInnerError<W> { 188 /// } 189 /// }; 190 /// ``` 191- #[stable(feature = "rust1", since = "1.0.0")] 192 pub fn error(&self) -> &Error { &self.1 } 193 194 /// Returns the buffered writer instance which generated the error. 195@@ -575,23 +553,13 @@ impl<W> IntoInnerError<W> { 196 /// } 197 /// }; 198 /// ``` 199- #[stable(feature = "rust1", since = "1.0.0")] 200 pub fn into_inner(self) -> W { self.0 } 201 } 202 203-#[stable(feature = "rust1", since = "1.0.0")] 204 impl<W> From<IntoInnerError<W>> for Error { 205 fn from(iie: IntoInnerError<W>) -> Error { iie.1 } 206 } 207 208-#[stable(feature = "rust1", since = "1.0.0")] 209-impl<W: Send + fmt::Debug> error::Error for IntoInnerError<W> { 210- fn description(&self) -> &str { 211- error::Error::description(self.error()) 212- } 213-} 214- 215-#[stable(feature = "rust1", since = "1.0.0")] 216 impl<W> fmt::Display for IntoInnerError<W> { 217 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 218 self.error().fmt(f) 219@@ -646,7 +614,6 @@ impl<W> fmt::Display for IntoInnerError<W> { 220 /// # Ok(()) 221 /// # } 222 /// ``` 223-#[stable(feature = "rust1", since = "1.0.0")] 224 pub struct LineWriter<W: Write> { 225 inner: BufWriter<W>, 226 } 227@@ -666,7 +633,6 @@ impl<W: Write> LineWriter<W> { 228 /// # Ok(()) 229 /// # } 230 /// ``` 231- #[stable(feature = "rust1", since = "1.0.0")] 232 pub fn new(inner: W) -> LineWriter<W> { 233 // Lines typically aren't that long, don't use a giant buffer 234 LineWriter::with_capacity(1024, inner) 235@@ -687,7 +653,6 @@ impl<W: Write> LineWriter<W> { 236 /// # Ok(()) 237 /// # } 238 /// ``` 239- #[stable(feature = "rust1", since = "1.0.0")] 240 pub fn with_capacity(cap: usize, inner: W) -> LineWriter<W> { 241 LineWriter { inner: BufWriter::with_capacity(cap, inner) } 242 } 243@@ -708,7 +673,6 @@ impl<W: Write> LineWriter<W> { 244 /// # Ok(()) 245 /// # } 246 /// ``` 247- #[stable(feature = "rust1", since = "1.0.0")] 248 pub fn get_ref(&self) -> &W { self.inner.get_ref() } 249 250 /// Gets a mutable reference to the underlying writer. 251@@ -731,7 +695,6 @@ impl<W: Write> LineWriter<W> { 252 /// # Ok(()) 253 /// # } 254 /// ``` 255- #[stable(feature = "rust1", since = "1.0.0")] 256 pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } 257 258 /// Unwraps this `LineWriter`, returning the underlying writer. 259@@ -753,7 +716,6 @@ impl<W: Write> LineWriter<W> { 260 /// # Ok(()) 261 /// # } 262 /// ``` 263- #[stable(feature = "rust1", since = "1.0.0")] 264 pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>> { 265 self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { 266 IntoInnerError(LineWriter { inner: buf }, e) 267@@ -761,7 +723,6 @@ impl<W: Write> LineWriter<W> { 268 } 269 } 270 271-#[stable(feature = "rust1", since = "1.0.0")] 272 impl<W: Write> Write for LineWriter<W> { 273 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { 274 match memchr::memrchr(b'\n', buf) { 275@@ -780,7 +741,6 @@ impl<W: Write> Write for LineWriter<W> { 276 fn flush(&mut self) -> io::Result<()> { self.inner.flush() } 277 } 278 279-#[stable(feature = "rust1", since = "1.0.0")] 280 impl<W: Write> fmt::Debug for LineWriter<W> where W: fmt::Debug { 281 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { 282 fmt.debug_struct("LineWriter") 283diff --git a/cursor.rs b/cursor.rs 284index ae0085f..0f8029d 100644 285--- a/cursor.rs 286+++ b/cursor.rs 287@@ -8,10 +8,11 @@ 288 // option. This file may not be copied, modified, or distributed 289 // except according to those terms. 290 291+use core::prelude::v1::*; 292 use io::prelude::*; 293 294-use core::convert::TryInto; 295-use cmp; 296+#[cfg(feature = "collections")] use core::convert::TryInto; 297+use core::cmp; 298 use io::{self, SeekFrom, Error, ErrorKind}; 299 300 /// A `Cursor` wraps another type and provides it with a 301@@ -73,7 +74,6 @@ use io::{self, SeekFrom, Error, ErrorKind}; 302 /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); 303 /// } 304 /// ``` 305-#[stable(feature = "rust1", since = "1.0.0")] 306 #[derive(Clone, Debug)] 307 pub struct Cursor<T> { 308 inner: T, 309@@ -92,7 +92,6 @@ impl<T> Cursor<T> { 310 /// # fn force_inference(_: &Cursor<Vec<u8>>) {} 311 /// # force_inference(&buff); 312 /// ``` 313- #[stable(feature = "rust1", since = "1.0.0")] 314 pub fn new(inner: T) -> Cursor<T> { 315 Cursor { pos: 0, inner: inner } 316 } 317@@ -110,7 +109,6 @@ impl<T> Cursor<T> { 318 /// 319 /// let vec = buff.into_inner(); 320 /// ``` 321- #[stable(feature = "rust1", since = "1.0.0")] 322 pub fn into_inner(self) -> T { self.inner } 323 324 /// Gets a reference to the underlying value in this cursor. 325@@ -126,7 +124,6 @@ impl<T> Cursor<T> { 326 /// 327 /// let reference = buff.get_ref(); 328 /// ``` 329- #[stable(feature = "rust1", since = "1.0.0")] 330 pub fn get_ref(&self) -> &T { &self.inner } 331 332 /// Gets a mutable reference to the underlying value in this cursor. 333@@ -145,7 +142,6 @@ impl<T> Cursor<T> { 334 /// 335 /// let reference = buff.get_mut(); 336 /// ``` 337- #[stable(feature = "rust1", since = "1.0.0")] 338 pub fn get_mut(&mut self) -> &mut T { &mut self.inner } 339 340 /// Returns the current position of this cursor. 341@@ -167,7 +163,6 @@ impl<T> Cursor<T> { 342 /// buff.seek(SeekFrom::Current(-1)).unwrap(); 343 /// assert_eq!(buff.position(), 1); 344 /// ``` 345- #[stable(feature = "rust1", since = "1.0.0")] 346 pub fn position(&self) -> u64 { self.pos } 347 348 /// Sets the position of this cursor. 349@@ -187,11 +182,9 @@ impl<T> Cursor<T> { 350 /// buff.set_position(4); 351 /// assert_eq!(buff.position(), 4); 352 /// ``` 353- #[stable(feature = "rust1", since = "1.0.0")] 354 pub fn set_position(&mut self, pos: u64) { self.pos = pos; } 355 } 356 357-#[stable(feature = "rust1", since = "1.0.0")] 358 impl<T> io::Seek for Cursor<T> where T: AsRef<[u8]> { 359 fn seek(&mut self, style: SeekFrom) -> io::Result<u64> { 360 let pos = match style { 361@@ -210,25 +203,27 @@ impl<T> io::Seek for Cursor<T> where T: AsRef<[u8]> { 362 } 363 } 364 365-#[stable(feature = "rust1", since = "1.0.0")] 366 impl<T> Read for Cursor<T> where T: AsRef<[u8]> { 367 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { 368- let n = Read::read(&mut self.fill_buf()?, buf)?; 369+ let n = Read::read(&mut self.get_buf()?, buf)?; 370 self.pos += n as u64; 371 Ok(n) 372 } 373 } 374 375-#[stable(feature = "rust1", since = "1.0.0")] 376-impl<T> BufRead for Cursor<T> where T: AsRef<[u8]> { 377- fn fill_buf(&mut self) -> io::Result<&[u8]> { 378+impl<T> Cursor<T> where T: AsRef<[u8]> { 379+ fn get_buf(&mut self) -> io::Result<&[u8]> { 380 let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); 381 Ok(&self.inner.as_ref()[(amt as usize)..]) 382 } 383+} 384+ 385+#[cfg(feature = "collections")] 386+impl<T> BufRead for Cursor<T> where T: AsRef<[u8]> { 387+ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } 388 fn consume(&mut self, amt: usize) { self.pos += amt as u64; } 389 } 390 391-#[stable(feature = "rust1", since = "1.0.0")] 392 impl<'a> Write for Cursor<&'a mut [u8]> { 393 #[inline] 394 fn write(&mut self, data: &[u8]) -> io::Result<usize> { 395@@ -240,7 +235,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { 396 fn flush(&mut self) -> io::Result<()> { Ok(()) } 397 } 398 399-#[stable(feature = "rust1", since = "1.0.0")] 400+#[cfg(feature = "collections")] 401 impl Write for Cursor<Vec<u8>> { 402 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { 403 let pos: usize = self.position().try_into().map_err(|_| { 404@@ -270,8 +265,8 @@ impl Write for Cursor<Vec<u8>> { 405 fn flush(&mut self) -> io::Result<()> { Ok(()) } 406 } 407 408-#[stable(feature = "cursor_box_slice", since = "1.5.0")] 409-impl Write for Cursor<Box<[u8]>> { 410+#[cfg(feature = "alloc")] 411+impl Write for Cursor<::alloc::boxed::Box<[u8]>> { 412 #[inline] 413 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { 414 let pos = cmp::min(self.pos, self.inner.len() as u64); 415diff --git a/error.rs b/error.rs 416index ddf0030..748b830 100644 417--- a/error.rs 418+++ b/error.rs 419@@ -8,10 +8,15 @@ 420 // option. This file may not be copied, modified, or distributed 421 // except according to those terms. 422 423-use error; 424-use fmt; 425-use result; 426-use sys; 427+#[cfg(feature="alloc")] use alloc::boxed::Box; 428+#[cfg(not(feature="alloc"))] use ::FakeBox as Box; 429+use core::convert::Into; 430+use core::fmt; 431+use core::marker::{Send, Sync}; 432+use core::option::Option::{self, Some, None}; 433+use core::result; 434+#[cfg(feature="collections")] use collections::string::String; 435+#[cfg(not(feature="collections"))] use ::ErrorString as String; 436 437 /// A specialized [`Result`](../result/enum.Result.html) type for I/O 438 /// operations. 439@@ -43,7 +48,6 @@ use sys; 440 /// Ok(buffer) 441 /// } 442 /// ``` 443-#[stable(feature = "rust1", since = "1.0.0")] 444 pub type Result<T> = result::Result<T, Error>; 445 446 /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and 447@@ -55,20 +59,22 @@ pub type Result<T> = result::Result<T, Error>; 448 /// 449 /// [`ErrorKind`]: enum.ErrorKind.html 450 #[derive(Debug)] 451-#[stable(feature = "rust1", since = "1.0.0")] 452 pub struct Error { 453 repr: Repr, 454 } 455 456 enum Repr { 457 Os(i32), 458+ #[cfg(feature="alloc")] 459 Custom(Box<Custom>), 460+ #[cfg(not(feature="alloc"))] 461+ Custom(Custom), 462 } 463 464 #[derive(Debug)] 465 struct Custom { 466 kind: ErrorKind, 467- error: Box<error::Error+Send+Sync>, 468+ error: String, 469 } 470 471 /// A list specifying general categories of I/O error. 472@@ -80,47 +86,34 @@ struct Custom { 473 /// 474 /// [`io::Error`]: struct.Error.html 475 #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] 476-#[stable(feature = "rust1", since = "1.0.0")] 477 #[allow(deprecated)] 478 pub enum ErrorKind { 479 /// An entity was not found, often a file. 480- #[stable(feature = "rust1", since = "1.0.0")] 481 NotFound, 482 /// The operation lacked the necessary privileges to complete. 483- #[stable(feature = "rust1", since = "1.0.0")] 484 PermissionDenied, 485 /// The connection was refused by the remote server. 486- #[stable(feature = "rust1", since = "1.0.0")] 487 ConnectionRefused, 488 /// The connection was reset by the remote server. 489- #[stable(feature = "rust1", since = "1.0.0")] 490 ConnectionReset, 491 /// The connection was aborted (terminated) by the remote server. 492- #[stable(feature = "rust1", since = "1.0.0")] 493 ConnectionAborted, 494 /// The network operation failed because it was not connected yet. 495- #[stable(feature = "rust1", since = "1.0.0")] 496 NotConnected, 497 /// A socket address could not be bound because the address is already in 498 /// use elsewhere. 499- #[stable(feature = "rust1", since = "1.0.0")] 500 AddrInUse, 501 /// A nonexistent interface was requested or the requested address was not 502 /// local. 503- #[stable(feature = "rust1", since = "1.0.0")] 504 AddrNotAvailable, 505 /// The operation failed because a pipe was closed. 506- #[stable(feature = "rust1", since = "1.0.0")] 507 BrokenPipe, 508 /// An entity already exists, often a file. 509- #[stable(feature = "rust1", since = "1.0.0")] 510 AlreadyExists, 511 /// The operation needs to block to complete, but the blocking operation was 512 /// requested to not occur. 513- #[stable(feature = "rust1", since = "1.0.0")] 514 WouldBlock, 515 /// A parameter was incorrect. 516- #[stable(feature = "rust1", since = "1.0.0")] 517 InvalidInput, 518 /// Data not valid for the operation were encountered. 519 /// 520@@ -130,10 +123,8 @@ pub enum ErrorKind { 521 /// 522 /// For example, a function that reads a file into a string will error with 523 /// `InvalidData` if the file's contents are not valid UTF-8. 524- #[stable(feature = "io_invalid_data", since = "1.2.0")] 525 InvalidData, 526 /// The I/O operation's timeout expired, causing it to be canceled. 527- #[stable(feature = "rust1", since = "1.0.0")] 528 TimedOut, 529 /// An error returned when an operation could not be completed because a 530 /// call to `write` returned `Ok(0)`. 531@@ -141,15 +132,12 @@ pub enum ErrorKind { 532 /// This typically means that an operation could only succeed if it wrote a 533 /// particular number of bytes but only a smaller number of bytes could be 534 /// written. 535- #[stable(feature = "rust1", since = "1.0.0")] 536 WriteZero, 537 /// This operation was interrupted. 538 /// 539 /// Interrupted operations can typically be retried. 540- #[stable(feature = "rust1", since = "1.0.0")] 541 Interrupted, 542 /// Any I/O error not part of this list. 543- #[stable(feature = "rust1", since = "1.0.0")] 544 Other, 545 546 /// An error returned when an operation could not be completed because an 547@@ -158,15 +146,10 @@ pub enum ErrorKind { 548 /// This typically means that an operation could only succeed if it read a 549 /// particular number of bytes but only a smaller number of bytes could be 550 /// read. 551- #[stable(feature = "read_exact", since = "1.6.0")] 552 UnexpectedEof, 553 554 /// A marker variant that tells the compiler that users of this enum cannot 555 /// match it exhaustively. 556- #[unstable(feature = "io_error_internals", 557- reason = "better expressed through extensible enums that this \ 558- enum cannot be exhaustively matched against", 559- issue = "0")] 560 #[doc(hidden)] 561 __Nonexhaustive, 562 } 563@@ -190,14 +173,13 @@ impl Error { 564 /// // errors can also be created from other errors 565 /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); 566 /// ``` 567- #[stable(feature = "rust1", since = "1.0.0")] 568 pub fn new<E>(kind: ErrorKind, error: E) -> Error 569- where E: Into<Box<error::Error+Send+Sync>> 570+ where E: Into<String> 571 { 572 Self::_new(kind, error.into()) 573 } 574 575- fn _new(kind: ErrorKind, error: Box<error::Error+Send+Sync>) -> Error { 576+ fn _new(kind: ErrorKind, error: String) -> Error { 577 Error { 578 repr: Repr::Custom(Box::new(Custom { 579 kind: kind, 580@@ -206,24 +188,6 @@ impl Error { 581 } 582 } 583 584- /// Returns an error representing the last OS error which occurred. 585- /// 586- /// This function reads the value of `errno` for the target platform (e.g. 587- /// `GetLastError` on Windows) and will return a corresponding instance of 588- /// `Error` for the error code. 589- /// 590- /// # Examples 591- /// 592- /// ``` 593- /// use std::io::Error; 594- /// 595- /// println!("last OS error: {:?}", Error::last_os_error()); 596- /// ``` 597- #[stable(feature = "rust1", since = "1.0.0")] 598- pub fn last_os_error() -> Error { 599- Error::from_raw_os_error(sys::os::errno() as i32) 600- } 601- 602 /// Creates a new instance of an `Error` from a particular OS error code. 603 /// 604 /// # Examples 605@@ -249,7 +213,6 @@ impl Error { 606 /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); 607 /// # } 608 /// ``` 609- #[stable(feature = "rust1", since = "1.0.0")] 610 pub fn from_raw_os_error(code: i32) -> Error { 611 Error { repr: Repr::Os(code) } 612 } 613@@ -280,7 +243,6 @@ impl Error { 614 /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); 615 /// } 616 /// ``` 617- #[stable(feature = "rust1", since = "1.0.0")] 618 pub fn raw_os_error(&self) -> Option<i32> { 619 match self.repr { 620 Repr::Os(i) => Some(i), 621@@ -313,11 +275,10 @@ impl Error { 622 /// print_error(&Error::new(ErrorKind::Other, "oh no!")); 623 /// } 624 /// ``` 625- #[stable(feature = "io_error_inner", since = "1.3.0")] 626- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { 627+ pub fn get_ref(&self) -> Option<&String> { 628 match self.repr { 629 Repr::Os(..) => None, 630- Repr::Custom(ref c) => Some(&*c.error), 631+ Repr::Custom(ref c) => Some(&c.error), 632 } 633 } 634 635@@ -383,11 +344,10 @@ impl Error { 636 /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); 637 /// } 638 /// ``` 639- #[stable(feature = "io_error_inner", since = "1.3.0")] 640- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { 641+ pub fn get_mut(&mut self) -> Option<&mut String> { 642 match self.repr { 643 Repr::Os(..) => None, 644- Repr::Custom(ref mut c) => Some(&mut *c.error), 645+ Repr::Custom(ref mut c) => Some(&mut c.error), 646 } 647 } 648 649@@ -416,8 +376,7 @@ impl Error { 650 /// print_error(Error::new(ErrorKind::Other, "oh no!")); 651 /// } 652 /// ``` 653- #[stable(feature = "io_error_inner", since = "1.3.0")] 654- pub fn into_inner(self) -> Option<Box<error::Error+Send+Sync>> { 655+ pub fn into_inner(self) -> Option<String> { 656 match self.repr { 657 Repr::Os(..) => None, 658 Repr::Custom(c) => Some(c.error) 659@@ -442,10 +401,9 @@ impl Error { 660 /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); 661 /// } 662 /// ``` 663- #[stable(feature = "rust1", since = "1.0.0")] 664 pub fn kind(&self) -> ErrorKind { 665 match self.repr { 666- Repr::Os(code) => sys::decode_error_kind(code), 667+ Repr::Os(_code) => ErrorKind::Other, 668 Repr::Custom(ref c) => c.kind, 669 } 670 } 671@@ -455,63 +413,23 @@ impl fmt::Debug for Repr { 672 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { 673 match *self { 674 Repr::Os(ref code) => 675- fmt.debug_struct("Os").field("code", code) 676- .field("message", &sys::os::error_string(*code)).finish(), 677+ fmt.debug_struct("Os").field("code", code).finish(), 678 Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), 679 } 680 } 681 } 682 683-#[stable(feature = "rust1", since = "1.0.0")] 684 impl fmt::Display for Error { 685 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { 686 match self.repr { 687 Repr::Os(code) => { 688- let detail = sys::os::error_string(code); 689- write!(fmt, "{} (os error {})", detail, code) 690+ write!(fmt, "os error {}", code) 691 } 692 Repr::Custom(ref c) => c.error.fmt(fmt), 693 } 694 } 695 } 696 697-#[stable(feature = "rust1", since = "1.0.0")] 698-impl error::Error for Error { 699- fn description(&self) -> &str { 700- match self.repr { 701- Repr::Os(..) => match self.kind() { 702- ErrorKind::NotFound => "entity not found", 703- ErrorKind::PermissionDenied => "permission denied", 704- ErrorKind::ConnectionRefused => "connection refused", 705- ErrorKind::ConnectionReset => "connection reset", 706- ErrorKind::ConnectionAborted => "connection aborted", 707- ErrorKind::NotConnected => "not connected", 708- ErrorKind::AddrInUse => "address in use", 709- ErrorKind::AddrNotAvailable => "address not available", 710- ErrorKind::BrokenPipe => "broken pipe", 711- ErrorKind::AlreadyExists => "entity already exists", 712- ErrorKind::WouldBlock => "operation would block", 713- ErrorKind::InvalidInput => "invalid input parameter", 714- ErrorKind::InvalidData => "invalid data", 715- ErrorKind::TimedOut => "timed out", 716- ErrorKind::WriteZero => "write zero", 717- ErrorKind::Interrupted => "operation interrupted", 718- ErrorKind::Other => "other os error", 719- ErrorKind::UnexpectedEof => "unexpected end of file", 720- ErrorKind::__Nonexhaustive => unreachable!() 721- }, 722- Repr::Custom(ref c) => c.error.description(), 723- } 724- } 725- 726- fn cause(&self) -> Option<&error::Error> { 727- match self.repr { 728- Repr::Os(..) => None, 729- Repr::Custom(ref c) => c.error.cause(), 730- } 731- } 732-} 733- 734 fn _assert_error_is_sync_send() { 735 fn _is_sync_send<T: Sync+Send>() {} 736 _is_sync_send::<Error>(); 737diff --git a/impls.rs b/impls.rs 738index cd05e6b..d048379 100644 739--- a/impls.rs 740+++ b/impls.rs 741@@ -8,26 +8,31 @@ 742 // option. This file may not be copied, modified, or distributed 743 // except according to those terms. 744 745-use cmp; 746-use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind}; 747-use fmt; 748-use mem; 749+#[cfg(feature="alloc")] use alloc::boxed::Box; 750+use core::cmp; 751+use io::{self, SeekFrom, Read, Write, Seek, Error, ErrorKind}; 752+#[cfg(feature="collections")] use io::BufRead; 753+use core::fmt; 754+use core::mem; 755+#[cfg(feature="collections")] use collections::string::String; 756+#[cfg(feature="collections")] use collections::vec::Vec; 757 758 // ============================================================================= 759 // Forwarding implementations 760 761-#[stable(feature = "rust1", since = "1.0.0")] 762 impl<'a, R: Read + ?Sized> Read for &'a mut R { 763 #[inline] 764 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { 765 (**self).read(buf) 766 } 767 768+ #[cfg(feature="collections")] 769 #[inline] 770 fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> { 771 (**self).read_to_end(buf) 772 } 773 774+ #[cfg(feature="collections")] 775 #[inline] 776 fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> { 777 (**self).read_to_string(buf) 778@@ -38,7 +43,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { 779 (**self).read_exact(buf) 780 } 781 } 782-#[stable(feature = "rust1", since = "1.0.0")] 783 impl<'a, W: Write + ?Sized> Write for &'a mut W { 784 #[inline] 785 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) } 786@@ -56,12 +60,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { 787 (**self).write_fmt(fmt) 788 } 789 } 790-#[stable(feature = "rust1", since = "1.0.0")] 791 impl<'a, S: Seek + ?Sized> Seek for &'a mut S { 792 #[inline] 793 fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) } 794 } 795-#[stable(feature = "rust1", since = "1.0.0")] 796+#[cfg(feature="collections")] 797 impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { 798 #[inline] 799 fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } 800@@ -80,18 +83,20 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { 801 } 802 } 803 804-#[stable(feature = "rust1", since = "1.0.0")] 805+#[cfg(feature="alloc")] 806 impl<R: Read + ?Sized> Read for Box<R> { 807 #[inline] 808 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { 809 (**self).read(buf) 810 } 811 812+ #[cfg(feature="collections")] 813 #[inline] 814 fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> { 815 (**self).read_to_end(buf) 816 } 817 818+ #[cfg(feature="collections")] 819 #[inline] 820 fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> { 821 (**self).read_to_string(buf) 822@@ -102,7 +107,7 @@ impl<R: Read + ?Sized> Read for Box<R> { 823 (**self).read_exact(buf) 824 } 825 } 826-#[stable(feature = "rust1", since = "1.0.0")] 827+#[cfg(feature="alloc")] 828 impl<W: Write + ?Sized> Write for Box<W> { 829 #[inline] 830 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) } 831@@ -120,12 +125,12 @@ impl<W: Write + ?Sized> Write for Box<W> { 832 (**self).write_fmt(fmt) 833 } 834 } 835-#[stable(feature = "rust1", since = "1.0.0")] 836+#[cfg(feature="alloc")] 837 impl<S: Seek + ?Sized> Seek for Box<S> { 838 #[inline] 839 fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) } 840 } 841-#[stable(feature = "rust1", since = "1.0.0")] 842+#[cfg(feature="collections")] 843 impl<B: BufRead + ?Sized> BufRead for Box<B> { 844 #[inline] 845 fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } 846@@ -147,7 +152,6 @@ impl<B: BufRead + ?Sized> BufRead for Box<B> { 847 // ============================================================================= 848 // In-memory buffer implementations 849 850-#[stable(feature = "rust1", since = "1.0.0")] 851 impl<'a> Read for &'a [u8] { 852 #[inline] 853 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { 854@@ -171,7 +175,7 @@ impl<'a> Read for &'a [u8] { 855 } 856 } 857 858-#[stable(feature = "rust1", since = "1.0.0")] 859+#[cfg(feature="collections")] 860 impl<'a> BufRead for &'a [u8] { 861 #[inline] 862 fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } 863@@ -180,7 +184,6 @@ impl<'a> BufRead for &'a [u8] { 864 fn consume(&mut self, amt: usize) { *self = &self[amt..]; } 865 } 866 867-#[stable(feature = "rust1", since = "1.0.0")] 868 impl<'a> Write for &'a mut [u8] { 869 #[inline] 870 fn write(&mut self, data: &[u8]) -> io::Result<usize> { 871@@ -204,7 +207,7 @@ impl<'a> Write for &'a mut [u8] { 872 fn flush(&mut self) -> io::Result<()> { Ok(()) } 873 } 874 875-#[stable(feature = "rust1", since = "1.0.0")] 876+#[cfg(feature="collections")] 877 impl Write for Vec<u8> { 878 #[inline] 879 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { 880diff --git a/memchr.rs b/memchr.rs 881index 3824a5f..312cf47 100644 882--- a/memchr.rs 883+++ b/memchr.rs 884@@ -11,10 +11,12 @@ 885 // Original implementation taken from rust-memchr 886 // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch 887 888+pub use self::fallback::{memchr,memrchr}; 889+ 890 #[allow(dead_code)] 891 pub mod fallback { 892- use cmp; 893- use mem; 894+ use core::cmp; 895+ use core::mem; 896 897 const LO_U64: u64 = 0x0101010101010101; 898 const HI_U64: u64 = 0x8080808080808080; 899diff --git a/mod.rs b/mod.rs 900index 14d046a..e71dca0 100644 901--- a/mod.rs 902+++ b/mod.rs 903@@ -252,42 +252,32 @@ 904 //! [`io::Result`]: type.Result.html 905 //! [`try!`]: ../macro.try.html 906 907-#![stable(feature = "rust1", since = "1.0.0")] 908- 909-use cmp; 910+use core::cmp; 911 use rustc_unicode::str as core_str; 912-use error as std_error; 913-use fmt; 914-use result; 915-use str; 916-use memchr; 917- 918-#[stable(feature = "rust1", since = "1.0.0")] 919-pub use self::buffered::{BufReader, BufWriter, LineWriter}; 920-#[stable(feature = "rust1", since = "1.0.0")] 921-pub use self::buffered::IntoInnerError; 922-#[stable(feature = "rust1", since = "1.0.0")] 923+use core::fmt; 924+use core::iter::{Iterator}; 925+use core::marker::Sized; 926+#[cfg(feature="collections")] use core::ops::{Drop, FnOnce}; 927+use core::option::Option::{self, Some, None}; 928+use core::result::Result::{Ok, Err}; 929+use core::result; 930+#[cfg(feature="collections")] use collections::string::String; 931+use core::str; 932+#[cfg(feature="collections")] use collections::vec::Vec; 933+mod memchr; 934+ 935+#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; 936+#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; 937 pub use self::cursor::Cursor; 938-#[stable(feature = "rust1", since = "1.0.0")] 939 pub use self::error::{Result, Error, ErrorKind}; 940-#[stable(feature = "rust1", since = "1.0.0")] 941 pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; 942-#[stable(feature = "rust1", since = "1.0.0")] 943-pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr}; 944-#[stable(feature = "rust1", since = "1.0.0")] 945-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; 946-#[unstable(feature = "libstd_io_internals", issue = "0")] 947-#[doc(no_inline, hidden)] 948-pub use self::stdio::{set_panic, set_print}; 949 950 pub mod prelude; 951-mod buffered; 952+#[cfg(feature="collections")] mod buffered; 953 mod cursor; 954 mod error; 955 mod impls; 956-mod lazy; 957 mod util; 958-mod stdio; 959 960 const DEFAULT_BUF_SIZE: usize = 8 * 1024; 961 962@@ -309,6 +299,7 @@ const DEFAULT_BUF_SIZE: usize = 8 * 1024; 963 // 2. We're passing a raw buffer to the function `f`, and it is expected that 964 // the function only *appends* bytes to the buffer. We'll get undefined 965 // behavior if existing bytes are overwritten to have non-UTF-8 data. 966+#[cfg(feature="collections")] 967 fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize> 968 where F: FnOnce(&mut Vec<u8>) -> Result<usize> 969 { 970@@ -340,6 +331,7 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize> 971 // of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every 972 // time is 4,500 times (!) slower than this if the reader has a very small 973 // amount of data to return. 974+#[cfg(feature="collections")] 975 fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> { 976 let start_len = buf.len(); 977 let mut len = start_len; 978@@ -422,7 +414,6 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> 979 /// # Ok(()) 980 /// # } 981 /// ``` 982-#[stable(feature = "rust1", since = "1.0.0")] 983 pub trait Read { 984 /// Pull some bytes from this source into the specified buffer, returning 985 /// how many bytes were read. 986@@ -472,7 +463,6 @@ pub trait Read { 987 /// # Ok(()) 988 /// # } 989 /// ``` 990- #[stable(feature = "rust1", since = "1.0.0")] 991 fn read(&mut self, buf: &mut [u8]) -> Result<usize>; 992 993 /// Read all bytes until EOF in this source, placing them into `buf`. 994@@ -514,7 +504,7 @@ pub trait Read { 995 /// # Ok(()) 996 /// # } 997 /// ``` 998- #[stable(feature = "rust1", since = "1.0.0")] 999+ #[cfg(feature="collections")] 1000 fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> { 1001 read_to_end(self, buf) 1002 } 1003@@ -552,7 +542,7 @@ pub trait Read { 1004 /// # Ok(()) 1005 /// # } 1006 /// ``` 1007- #[stable(feature = "rust1", since = "1.0.0")] 1008+ #[cfg(feature="collections")] 1009 fn read_to_string(&mut self, buf: &mut String) -> Result<usize> { 1010 // Note that we do *not* call `.read_to_end()` here. We are passing 1011 // `&mut Vec<u8>` (the raw contents of `buf`) into the `read_to_end` 1012@@ -613,7 +603,6 @@ pub trait Read { 1013 /// # Ok(()) 1014 /// # } 1015 /// ``` 1016- #[stable(feature = "read_exact", since = "1.6.0")] 1017 fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { 1018 while !buf.is_empty() { 1019 match self.read(buf) { 1020@@ -665,7 +654,6 @@ pub trait Read { 1021 /// # Ok(()) 1022 /// # } 1023 /// ``` 1024- #[stable(feature = "rust1", since = "1.0.0")] 1025 fn by_ref(&mut self) -> &mut Self where Self: Sized { self } 1026 1027 /// Transforms this `Read` instance to an `Iterator` over its bytes. 1028@@ -695,7 +683,6 @@ pub trait Read { 1029 /// # Ok(()) 1030 /// # } 1031 /// ``` 1032- #[stable(feature = "rust1", since = "1.0.0")] 1033 fn bytes(self) -> Bytes<Self> where Self: Sized { 1034 Bytes { inner: self } 1035 } 1036@@ -732,10 +719,6 @@ pub trait Read { 1037 /// # Ok(()) 1038 /// # } 1039 /// ``` 1040- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ 1041- of where errors happen is currently \ 1042- unclear and may change", 1043- issue = "27802")] 1044 fn chars(self) -> Chars<Self> where Self: Sized { 1045 Chars { inner: self } 1046 } 1047@@ -770,7 +753,6 @@ pub trait Read { 1048 /// # Ok(()) 1049 /// # } 1050 /// ``` 1051- #[stable(feature = "rust1", since = "1.0.0")] 1052 fn chain<R: Read>(self, next: R) -> Chain<Self, R> where Self: Sized { 1053 Chain { first: self, second: next, done_first: false } 1054 } 1055@@ -804,7 +786,6 @@ pub trait Read { 1056 /// # Ok(()) 1057 /// # } 1058 /// ``` 1059- #[stable(feature = "rust1", since = "1.0.0")] 1060 fn take(self, limit: u64) -> Take<Self> where Self: Sized { 1061 Take { inner: self, limit: limit } 1062 } 1063@@ -840,7 +821,6 @@ pub trait Read { 1064 /// # Ok(()) 1065 /// # } 1066 /// ``` 1067-#[stable(feature = "rust1", since = "1.0.0")] 1068 pub trait Write { 1069 /// Write a buffer into this object, returning how many bytes were written. 1070 /// 1071@@ -880,7 +860,6 @@ pub trait Write { 1072 /// # Ok(()) 1073 /// # } 1074 /// ``` 1075- #[stable(feature = "rust1", since = "1.0.0")] 1076 fn write(&mut self, buf: &[u8]) -> Result<usize>; 1077 1078 /// Flush this output stream, ensuring that all intermediately buffered 1079@@ -906,7 +885,6 @@ pub trait Write { 1080 /// # Ok(()) 1081 /// # } 1082 /// ``` 1083- #[stable(feature = "rust1", since = "1.0.0")] 1084 fn flush(&mut self) -> Result<()>; 1085 1086 /// Attempts to write an entire buffer into this write. 1087@@ -933,7 +911,6 @@ pub trait Write { 1088 /// # Ok(()) 1089 /// # } 1090 /// ``` 1091- #[stable(feature = "rust1", since = "1.0.0")] 1092 fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { 1093 while !buf.is_empty() { 1094 match self.write(buf) { 1095@@ -985,7 +962,6 @@ pub trait Write { 1096 /// # Ok(()) 1097 /// # } 1098 /// ``` 1099- #[stable(feature = "rust1", since = "1.0.0")] 1100 fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { 1101 // Create a shim which translates a Write to a fmt::Write and saves 1102 // off I/O errors. instead of discarding them 1103@@ -1041,7 +1017,6 @@ pub trait Write { 1104 /// # Ok(()) 1105 /// # } 1106 /// ``` 1107- #[stable(feature = "rust1", since = "1.0.0")] 1108 fn by_ref(&mut self) -> &mut Self where Self: Sized { self } 1109 } 1110 1111@@ -1071,7 +1046,6 @@ pub trait Write { 1112 /// # Ok(()) 1113 /// # } 1114 /// ``` 1115-#[stable(feature = "rust1", since = "1.0.0")] 1116 pub trait Seek { 1117 /// Seek to an offset, in bytes, in a stream. 1118 /// 1119@@ -1087,7 +1061,6 @@ pub trait Seek { 1120 /// Seeking to a negative offset is considered an error. 1121 /// 1122 /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start 1123- #[stable(feature = "rust1", since = "1.0.0")] 1124 fn seek(&mut self, pos: SeekFrom) -> Result<u64>; 1125 } 1126 1127@@ -1097,29 +1070,26 @@ pub trait Seek { 1128 /// 1129 /// [`Seek`]: trait.Seek.html 1130 #[derive(Copy, PartialEq, Eq, Clone, Debug)] 1131-#[stable(feature = "rust1", since = "1.0.0")] 1132 pub enum SeekFrom { 1133 /// Set the offset to the provided number of bytes. 1134- #[stable(feature = "rust1", since = "1.0.0")] 1135- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), 1136+ Start(u64), 1137 1138 /// Set the offset to the size of this object plus the specified number of 1139 /// bytes. 1140 /// 1141 /// It is possible to seek beyond the end of an object, but it's an error to 1142 /// seek before byte 0. 1143- #[stable(feature = "rust1", since = "1.0.0")] 1144- End(#[stable(feature = "rust1", since = "1.0.0")] i64), 1145+ End(i64), 1146 1147 /// Set the offset to the current position plus the specified number of 1148 /// bytes. 1149 /// 1150 /// It is possible to seek beyond the end of an object, but it's an error to 1151 /// seek before byte 0. 1152- #[stable(feature = "rust1", since = "1.0.0")] 1153- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), 1154+ Current(i64), 1155 } 1156 1157+#[cfg(feature="collections")] 1158 fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) 1159 -> Result<usize> { 1160 let mut read = 0; 1161@@ -1199,7 +1169,7 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) 1162 /// # } 1163 /// ``` 1164 /// 1165-#[stable(feature = "rust1", since = "1.0.0")] 1166+#[cfg(feature="collections")] 1167 pub trait BufRead: Read { 1168 /// Fills the internal buffer of this object, returning the buffer contents. 1169 /// 1170@@ -1244,7 +1214,6 @@ pub trait BufRead: Read { 1171 /// // ensure the bytes we worked with aren't returned again later 1172 /// stdin.consume(length); 1173 /// ``` 1174- #[stable(feature = "rust1", since = "1.0.0")] 1175 fn fill_buf(&mut self) -> Result<&[u8]>; 1176 1177 /// Tells this buffer that `amt` bytes have been consumed from the buffer, 1178@@ -1266,7 +1235,6 @@ pub trait BufRead: Read { 1179 /// 1180 /// Since `consume()` is meant to be used with [`fill_buf()`][fillbuf], 1181 /// that method's example includes an example of `consume()`. 1182- #[stable(feature = "rust1", since = "1.0.0")] 1183 fn consume(&mut self, amt: usize); 1184 1185 /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. 1186@@ -1305,7 +1273,6 @@ pub trait BufRead: Read { 1187 /// # Ok(()) 1188 /// # } 1189 /// ``` 1190- #[stable(feature = "rust1", since = "1.0.0")] 1191 fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize> { 1192 read_until(self, byte, buf) 1193 } 1194@@ -1351,7 +1318,6 @@ pub trait BufRead: Read { 1195 /// buffer.clear(); 1196 /// } 1197 /// ``` 1198- #[stable(feature = "rust1", since = "1.0.0")] 1199 fn read_line(&mut self, buf: &mut String) -> Result<usize> { 1200 // Note that we are not calling the `.read_until` method here, but 1201 // rather our hardcoded implementation. For more details as to why, see 1202@@ -1384,7 +1350,6 @@ pub trait BufRead: Read { 1203 /// println!("{:?}", content.unwrap()); 1204 /// } 1205 /// ``` 1206- #[stable(feature = "rust1", since = "1.0.0")] 1207 fn split(self, byte: u8) -> Split<Self> where Self: Sized { 1208 Split { buf: self, delim: byte } 1209 } 1210@@ -1409,7 +1374,6 @@ pub trait BufRead: Read { 1211 /// println!("{}", line.unwrap()); 1212 /// } 1213 /// ``` 1214- #[stable(feature = "rust1", since = "1.0.0")] 1215 fn lines(self) -> Lines<Self> where Self: Sized { 1216 Lines { buf: self } 1217 } 1218@@ -1421,14 +1385,12 @@ pub trait BufRead: Read { 1219 /// Please see the documentation of `chain()` for more details. 1220 /// 1221 /// [chain]: trait.Read.html#method.chain 1222-#[stable(feature = "rust1", since = "1.0.0")] 1223 pub struct Chain<T, U> { 1224 first: T, 1225 second: U, 1226 done_first: bool, 1227 } 1228 1229-#[stable(feature = "rust1", since = "1.0.0")] 1230 impl<T: Read, U: Read> Read for Chain<T, U> { 1231 fn read(&mut self, buf: &mut [u8]) -> Result<usize> { 1232 if !self.done_first { 1233@@ -1441,7 +1403,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> { 1234 } 1235 } 1236 1237-#[stable(feature = "chain_bufread", since = "1.9.0")] 1238+#[cfg(feature="collections")] 1239 impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> { 1240 fn fill_buf(&mut self) -> Result<&[u8]> { 1241 if !self.done_first { 1242@@ -1468,7 +1430,6 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> { 1243 /// Please see the documentation of `take()` for more details. 1244 /// 1245 /// [take]: trait.Read.html#method.take 1246-#[stable(feature = "rust1", since = "1.0.0")] 1247 pub struct Take<T> { 1248 inner: T, 1249 limit: u64, 1250@@ -1500,7 +1461,6 @@ impl<T> Take<T> { 1251 /// # Ok(()) 1252 /// # } 1253 /// ``` 1254- #[stable(feature = "rust1", since = "1.0.0")] 1255 pub fn limit(&self) -> u64 { self.limit } 1256 1257 /// Consumes the `Take`, returning the wrapped reader. 1258@@ -1525,13 +1485,11 @@ impl<T> Take<T> { 1259 /// # Ok(()) 1260 /// # } 1261 /// ``` 1262- #[unstable(feature = "io_take_into_inner", issue = "23755")] 1263 pub fn into_inner(self) -> T { 1264 self.inner 1265 } 1266 } 1267 1268-#[stable(feature = "rust1", since = "1.0.0")] 1269 impl<T: Read> Read for Take<T> { 1270 fn read(&mut self, buf: &mut [u8]) -> Result<usize> { 1271 // Don't call into inner reader at all at EOF because it may still block 1272@@ -1546,7 +1504,7 @@ impl<T: Read> Read for Take<T> { 1273 } 1274 } 1275 1276-#[stable(feature = "rust1", since = "1.0.0")] 1277+#[cfg(feature="collections")] 1278 impl<T: BufRead> BufRead for Take<T> { 1279 fn fill_buf(&mut self) -> Result<&[u8]> { 1280 // Don't call into inner reader at all at EOF because it may still block 1281@@ -1585,12 +1543,10 @@ fn read_one_byte(reader: &mut Read) -> Option<Result<u8>> { 1282 /// Please see the documentation of `bytes()` for more details. 1283 /// 1284 /// [bytes]: trait.Read.html#method.bytes 1285-#[stable(feature = "rust1", since = "1.0.0")] 1286 pub struct Bytes<R> { 1287 inner: R, 1288 } 1289 1290-#[stable(feature = "rust1", since = "1.0.0")] 1291 impl<R: Read> Iterator for Bytes<R> { 1292 type Item = Result<u8>; 1293 1294@@ -1605,8 +1561,6 @@ impl<R: Read> Iterator for Bytes<R> { 1295 /// Please see the documentation of `chars()` for more details. 1296 /// 1297 /// [chars]: trait.Read.html#method.chars 1298-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", 1299- issue = "27802")] 1300 pub struct Chars<R> { 1301 inner: R, 1302 } 1303@@ -1614,8 +1568,6 @@ pub struct Chars<R> { 1304 /// An enumeration of possible errors that can be generated from the `Chars` 1305 /// adapter. 1306 #[derive(Debug)] 1307-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", 1308- issue = "27802")] 1309 pub enum CharsError { 1310 /// Variant representing that the underlying stream was read successfully 1311 /// but it did not contain valid utf8 data. 1312@@ -1625,8 +1577,6 @@ pub enum CharsError { 1313 Other(Error), 1314 } 1315 1316-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", 1317- issue = "27802")] 1318 impl<R: Read> Iterator for Chars<R> { 1319 type Item = result::Result<char, CharsError>; 1320 1321@@ -1658,25 +1608,6 @@ impl<R: Read> Iterator for Chars<R> { 1322 } 1323 } 1324 1325-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", 1326- issue = "27802")] 1327-impl std_error::Error for CharsError { 1328- fn description(&self) -> &str { 1329- match *self { 1330- CharsError::NotUtf8 => "invalid utf8 encoding", 1331- CharsError::Other(ref e) => std_error::Error::description(e), 1332- } 1333- } 1334- fn cause(&self) -> Option<&std_error::Error> { 1335- match *self { 1336- CharsError::NotUtf8 => None, 1337- CharsError::Other(ref e) => e.cause(), 1338- } 1339- } 1340-} 1341- 1342-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", 1343- issue = "27802")] 1344 impl fmt::Display for CharsError { 1345 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 1346 match *self { 1347@@ -1695,13 +1626,13 @@ impl fmt::Display for CharsError { 1348 /// `BufRead`. Please see the documentation of `split()` for more details. 1349 /// 1350 /// [split]: trait.BufRead.html#method.split 1351-#[stable(feature = "rust1", since = "1.0.0")] 1352+#[cfg(feature="collections")] 1353 pub struct Split<B> { 1354 buf: B, 1355 delim: u8, 1356 } 1357 1358-#[stable(feature = "rust1", since = "1.0.0")] 1359+#[cfg(feature="collections")] 1360 impl<B: BufRead> Iterator for Split<B> { 1361 type Item = Result<Vec<u8>>; 1362 1363@@ -1726,12 +1657,12 @@ impl<B: BufRead> Iterator for Split<B> { 1364 /// `BufRead`. Please see the documentation of `lines()` for more details. 1365 /// 1366 /// [lines]: trait.BufRead.html#method.lines 1367-#[stable(feature = "rust1", since = "1.0.0")] 1368+#[cfg(feature="collections")] 1369 pub struct Lines<B> { 1370 buf: B, 1371 } 1372 1373-#[stable(feature = "rust1", since = "1.0.0")] 1374+#[cfg(feature="collections")] 1375 impl<B: BufRead> Iterator for Lines<B> { 1376 type Item = Result<String>; 1377 1378diff --git a/prelude.rs b/prelude.rs 1379index 8772d0f..49d66c9 100644 1380--- a/prelude.rs 1381+++ b/prelude.rs 1382@@ -18,7 +18,8 @@ 1383 //! use std::io::prelude::*; 1384 //! ``` 1385 1386-#![stable(feature = "rust1", since = "1.0.0")] 1387+pub use super::{Read, Write, Seek}; 1388+#[cfg(feature="collections")] pub use super::BufRead; 1389 1390-#[stable(feature = "rust1", since = "1.0.0")] 1391-pub use super::{Read, Write, BufRead, Seek}; 1392+#[cfg(feature="collections")] pub use alloc::boxed::Box; 1393+#[cfg(feature="collections")] pub use collections::vec::Vec; 1394diff --git a/util.rs b/util.rs 1395index 2c68802..93bcfc3 100644 1396--- a/util.rs 1397+++ b/util.rs 1398@@ -10,7 +10,8 @@ 1399 1400 #![allow(missing_copy_implementations)] 1401 1402-use io::{self, Read, Write, ErrorKind, BufRead}; 1403+use io::{self, Read, Write, ErrorKind}; 1404+#[cfg(feature="collections")] use io::BufRead; 1405 1406 /// Copies the entire contents of a reader into a writer. 1407 /// 1408@@ -42,7 +43,6 @@ use io::{self, Read, Write, ErrorKind, BufRead}; 1409 /// # Ok(()) 1410 /// # } 1411 /// ``` 1412-#[stable(feature = "rust1", since = "1.0.0")] 1413 pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64> 1414 where R: Read, W: Write 1415 { 1416@@ -66,7 +66,6 @@ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result< 1417 /// the documentation of `empty()` for more details. 1418 /// 1419 /// [empty]: fn.empty.html 1420-#[stable(feature = "rust1", since = "1.0.0")] 1421 pub struct Empty { _priv: () } 1422 1423 /// Constructs a new handle to an empty reader. 1424@@ -84,14 +83,12 @@ pub struct Empty { _priv: () } 1425 /// io::empty().read_to_string(&mut buffer).unwrap(); 1426 /// assert!(buffer.is_empty()); 1427 /// ``` 1428-#[stable(feature = "rust1", since = "1.0.0")] 1429 pub fn empty() -> Empty { Empty { _priv: () } } 1430 1431-#[stable(feature = "rust1", since = "1.0.0")] 1432 impl Read for Empty { 1433 fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> { Ok(0) } 1434 } 1435-#[stable(feature = "rust1", since = "1.0.0")] 1436+#[cfg(feature="collections")] 1437 impl BufRead for Empty { 1438 fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } 1439 fn consume(&mut self, _n: usize) {} 1440@@ -103,7 +100,6 @@ impl BufRead for Empty { 1441 /// see the documentation of `repeat()` for more details. 1442 /// 1443 /// [repeat]: fn.repeat.html 1444-#[stable(feature = "rust1", since = "1.0.0")] 1445 pub struct Repeat { byte: u8 } 1446 1447 /// Creates an instance of a reader that infinitely repeats one byte. 1448@@ -120,10 +116,8 @@ pub struct Repeat { byte: u8 } 1449 /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); 1450 /// assert_eq!(buffer, [0b101, 0b101, 0b101]); 1451 /// ``` 1452-#[stable(feature = "rust1", since = "1.0.0")] 1453 pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } 1454 1455-#[stable(feature = "rust1", since = "1.0.0")] 1456 impl Read for Repeat { 1457 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { 1458 for slot in &mut *buf { 1459@@ -139,7 +133,6 @@ impl Read for Repeat { 1460 /// see the documentation of `sink()` for more details. 1461 /// 1462 /// [sink]: fn.sink.html 1463-#[stable(feature = "rust1", since = "1.0.0")] 1464 pub struct Sink { _priv: () } 1465 1466 /// Creates an instance of a writer which will successfully consume all data. 1467@@ -156,10 +149,8 @@ pub struct Sink { _priv: () } 1468 /// let num_bytes = io::sink().write(&buffer).unwrap(); 1469 /// assert_eq!(num_bytes, 5); 1470 /// ``` 1471-#[stable(feature = "rust1", since = "1.0.0")] 1472 pub fn sink() -> Sink { Sink { _priv: () } } 1473 1474-#[stable(feature = "rust1", since = "1.0.0")] 1475 impl Write for Sink { 1476 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { Ok(buf.len()) } 1477 fn flush(&mut self) -> io::Result<()> { Ok(()) } 1478