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