d40c593f42fafbac1ff3d827f6df96338b5b7d8b.patch 53 KB

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