9a2c8783d91624261317316f996d8d2d09b7b6a4.patch 53 KB

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