3cb78259862d37da082f628af3ccb54edf264fd0.patch 53 KB

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