871bd237ee233bce3c3ba964c0b3948d685d7902.patch 55 KB

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