e107c8b84969fbe52cae7c9fd61858fddc6e016b.patch 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568
  1. diff --git a/buffered.rs b/buffered.rs
  2. index 4ff8c6a..fd4eb13 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. @@ -476,7 +457,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. @@ -486,7 +466,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. @@ -496,7 +475,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. @@ -535,7 +513,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. @@ -568,23 +545,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. @@ -639,7 +606,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. @@ -659,7 +625,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. @@ -680,7 +645,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. @@ -701,7 +665,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. @@ -724,7 +687,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. @@ -746,7 +708,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. @@ -754,7 +715,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. @@ -773,7 +733,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 ddf0030..748b830 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(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
  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,15 +146,10 @@ 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. /// A marker variant that tells the compiler that users of this enum cannot
  509. /// match it exhaustively.
  510. - #[unstable(feature = "io_error_internals",
  511. - reason = "better expressed through extensible enums that this \
  512. - enum cannot be exhaustively matched against",
  513. - issue = "0")]
  514. #[doc(hidden)]
  515. __Nonexhaustive,
  516. }
  517. @@ -190,14 +173,13 @@ impl Error {
  518. /// // errors can also be created from other errors
  519. /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error);
  520. /// ```
  521. - #[stable(feature = "rust1", since = "1.0.0")]
  522. pub fn new<E>(kind: ErrorKind, error: E) -> Error
  523. - where E: Into<Box<error::Error+Send+Sync>>
  524. + where E: Into<String>
  525. {
  526. Self::_new(kind, error.into())
  527. }
  528. - fn _new(kind: ErrorKind, error: Box<error::Error+Send+Sync>) -> Error {
  529. + fn _new(kind: ErrorKind, error: String) -> Error {
  530. Error {
  531. repr: Repr::Custom(Box::new(Custom {
  532. kind: kind,
  533. @@ -206,24 +188,6 @@ impl Error {
  534. }
  535. }
  536. - /// Returns an error representing the last OS error which occurred.
  537. - ///
  538. - /// This function reads the value of `errno` for the target platform (e.g.
  539. - /// `GetLastError` on Windows) and will return a corresponding instance of
  540. - /// `Error` for the error code.
  541. - ///
  542. - /// # Examples
  543. - ///
  544. - /// ```
  545. - /// use std::io::Error;
  546. - ///
  547. - /// println!("last OS error: {:?}", Error::last_os_error());
  548. - /// ```
  549. - #[stable(feature = "rust1", since = "1.0.0")]
  550. - pub fn last_os_error() -> Error {
  551. - Error::from_raw_os_error(sys::os::errno() as i32)
  552. - }
  553. -
  554. /// Creates a new instance of an `Error` from a particular OS error code.
  555. ///
  556. /// # Examples
  557. @@ -249,7 +213,6 @@ impl Error {
  558. /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
  559. /// # }
  560. /// ```
  561. - #[stable(feature = "rust1", since = "1.0.0")]
  562. pub fn from_raw_os_error(code: i32) -> Error {
  563. Error { repr: Repr::Os(code) }
  564. }
  565. @@ -280,7 +243,6 @@ impl Error {
  566. /// print_os_error(&Error::new(ErrorKind::Other, "oh no!"));
  567. /// }
  568. /// ```
  569. - #[stable(feature = "rust1", since = "1.0.0")]
  570. pub fn raw_os_error(&self) -> Option<i32> {
  571. match self.repr {
  572. Repr::Os(i) => Some(i),
  573. @@ -313,11 +275,10 @@ impl Error {
  574. /// print_error(&Error::new(ErrorKind::Other, "oh no!"));
  575. /// }
  576. /// ```
  577. - #[stable(feature = "io_error_inner", since = "1.3.0")]
  578. - pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> {
  579. + pub fn get_ref(&self) -> Option<&String> {
  580. match self.repr {
  581. Repr::Os(..) => None,
  582. - Repr::Custom(ref c) => Some(&*c.error),
  583. + Repr::Custom(ref c) => Some(&c.error),
  584. }
  585. }
  586. @@ -383,11 +344,10 @@ impl Error {
  587. /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new())));
  588. /// }
  589. /// ```
  590. - #[stable(feature = "io_error_inner", since = "1.3.0")]
  591. - pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> {
  592. + pub fn get_mut(&mut self) -> Option<&mut String> {
  593. match self.repr {
  594. Repr::Os(..) => None,
  595. - Repr::Custom(ref mut c) => Some(&mut *c.error),
  596. + Repr::Custom(ref mut c) => Some(&mut c.error),
  597. }
  598. }
  599. @@ -416,8 +376,7 @@ impl Error {
  600. /// print_error(Error::new(ErrorKind::Other, "oh no!"));
  601. /// }
  602. /// ```
  603. - #[stable(feature = "io_error_inner", since = "1.3.0")]
  604. - pub fn into_inner(self) -> Option<Box<error::Error+Send+Sync>> {
  605. + pub fn into_inner(self) -> Option<String> {
  606. match self.repr {
  607. Repr::Os(..) => None,
  608. Repr::Custom(c) => Some(c.error)
  609. @@ -442,10 +401,9 @@ impl Error {
  610. /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!"));
  611. /// }
  612. /// ```
  613. - #[stable(feature = "rust1", since = "1.0.0")]
  614. pub fn kind(&self) -> ErrorKind {
  615. match self.repr {
  616. - Repr::Os(code) => sys::decode_error_kind(code),
  617. + Repr::Os(_code) => ErrorKind::Other,
  618. Repr::Custom(ref c) => c.kind,
  619. }
  620. }
  621. @@ -455,63 +413,23 @@ impl fmt::Debug for Repr {
  622. fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
  623. match *self {
  624. Repr::Os(ref code) =>
  625. - fmt.debug_struct("Os").field("code", code)
  626. - .field("message", &sys::os::error_string(*code)).finish(),
  627. + fmt.debug_struct("Os").field("code", code).finish(),
  628. Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(),
  629. }
  630. }
  631. }
  632. -#[stable(feature = "rust1", since = "1.0.0")]
  633. impl fmt::Display for Error {
  634. fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
  635. match self.repr {
  636. Repr::Os(code) => {
  637. - let detail = sys::os::error_string(code);
  638. - write!(fmt, "{} (os error {})", detail, code)
  639. + write!(fmt, "os error {}", code)
  640. }
  641. Repr::Custom(ref c) => c.error.fmt(fmt),
  642. }
  643. }
  644. }
  645. -#[stable(feature = "rust1", since = "1.0.0")]
  646. -impl error::Error for Error {
  647. - fn description(&self) -> &str {
  648. - match self.repr {
  649. - Repr::Os(..) => match self.kind() {
  650. - ErrorKind::NotFound => "entity not found",
  651. - ErrorKind::PermissionDenied => "permission denied",
  652. - ErrorKind::ConnectionRefused => "connection refused",
  653. - ErrorKind::ConnectionReset => "connection reset",
  654. - ErrorKind::ConnectionAborted => "connection aborted",
  655. - ErrorKind::NotConnected => "not connected",
  656. - ErrorKind::AddrInUse => "address in use",
  657. - ErrorKind::AddrNotAvailable => "address not available",
  658. - ErrorKind::BrokenPipe => "broken pipe",
  659. - ErrorKind::AlreadyExists => "entity already exists",
  660. - ErrorKind::WouldBlock => "operation would block",
  661. - ErrorKind::InvalidInput => "invalid input parameter",
  662. - ErrorKind::InvalidData => "invalid data",
  663. - ErrorKind::TimedOut => "timed out",
  664. - ErrorKind::WriteZero => "write zero",
  665. - ErrorKind::Interrupted => "operation interrupted",
  666. - ErrorKind::Other => "other os error",
  667. - ErrorKind::UnexpectedEof => "unexpected end of file",
  668. - ErrorKind::__Nonexhaustive => unreachable!()
  669. - },
  670. - Repr::Custom(ref c) => c.error.description(),
  671. - }
  672. - }
  673. -
  674. - fn cause(&self) -> Option<&error::Error> {
  675. - match self.repr {
  676. - Repr::Os(..) => None,
  677. - Repr::Custom(ref c) => c.error.cause(),
  678. - }
  679. - }
  680. -}
  681. -
  682. fn _assert_error_is_sync_send() {
  683. fn _is_sync_send<T: Sync+Send>() {}
  684. _is_sync_send::<Error>();
  685. diff --git a/impls.rs b/impls.rs
  686. index cd05e6b..d048379 100644
  687. --- a/impls.rs
  688. +++ b/impls.rs
  689. @@ -8,26 +8,31 @@
  690. // option. This file may not be copied, modified, or distributed
  691. // except according to those terms.
  692. -use cmp;
  693. -use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind};
  694. -use fmt;
  695. -use mem;
  696. +#[cfg(feature="alloc")] use alloc::boxed::Box;
  697. +use core::cmp;
  698. +use io::{self, SeekFrom, Read, Write, Seek, Error, ErrorKind};
  699. +#[cfg(feature="collections")] use io::BufRead;
  700. +use core::fmt;
  701. +use core::mem;
  702. +#[cfg(feature="collections")] use collections::string::String;
  703. +#[cfg(feature="collections")] use collections::vec::Vec;
  704. // =============================================================================
  705. // Forwarding implementations
  706. -#[stable(feature = "rust1", since = "1.0.0")]
  707. impl<'a, R: Read + ?Sized> Read for &'a mut R {
  708. #[inline]
  709. fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
  710. (**self).read(buf)
  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. @@ -38,7 +43,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. @@ -56,12 +60,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. @@ -80,18 +83,20 @@ 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. (**self).read(buf)
  752. }
  753. + #[cfg(feature="collections")]
  754. #[inline]
  755. fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
  756. (**self).read_to_end(buf)
  757. }
  758. + #[cfg(feature="collections")]
  759. #[inline]
  760. fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
  761. (**self).read_to_string(buf)
  762. @@ -102,7 +107,7 @@ impl<R: Read + ?Sized> Read for Box<R> {
  763. (**self).read_exact(buf)
  764. }
  765. }
  766. -#[stable(feature = "rust1", since = "1.0.0")]
  767. +#[cfg(feature="alloc")]
  768. impl<W: Write + ?Sized> Write for Box<W> {
  769. #[inline]
  770. fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) }
  771. @@ -120,12 +125,12 @@ impl<W: Write + ?Sized> Write for Box<W> {
  772. (**self).write_fmt(fmt)
  773. }
  774. }
  775. -#[stable(feature = "rust1", since = "1.0.0")]
  776. +#[cfg(feature="alloc")]
  777. impl<S: Seek + ?Sized> Seek for Box<S> {
  778. #[inline]
  779. fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
  780. }
  781. -#[stable(feature = "rust1", since = "1.0.0")]
  782. +#[cfg(feature="collections")]
  783. impl<B: BufRead + ?Sized> BufRead for Box<B> {
  784. #[inline]
  785. fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
  786. @@ -147,7 +152,6 @@ impl<B: BufRead + ?Sized> BufRead for Box<B> {
  787. // =============================================================================
  788. // In-memory buffer implementations
  789. -#[stable(feature = "rust1", since = "1.0.0")]
  790. impl<'a> Read for &'a [u8] {
  791. #[inline]
  792. fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
  793. @@ -171,7 +175,7 @@ impl<'a> Read for &'a [u8] {
  794. }
  795. }
  796. -#[stable(feature = "rust1", since = "1.0.0")]
  797. +#[cfg(feature="collections")]
  798. impl<'a> BufRead for &'a [u8] {
  799. #[inline]
  800. fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) }
  801. @@ -180,7 +184,6 @@ impl<'a> BufRead for &'a [u8] {
  802. fn consume(&mut self, amt: usize) { *self = &self[amt..]; }
  803. }
  804. -#[stable(feature = "rust1", since = "1.0.0")]
  805. impl<'a> Write for &'a mut [u8] {
  806. #[inline]
  807. fn write(&mut self, data: &[u8]) -> io::Result<usize> {
  808. @@ -204,7 +207,7 @@ impl<'a> Write for &'a mut [u8] {
  809. fn flush(&mut self) -> io::Result<()> { Ok(()) }
  810. }
  811. -#[stable(feature = "rust1", since = "1.0.0")]
  812. +#[cfg(feature="collections")]
  813. impl Write for Vec<u8> {
  814. #[inline]
  815. fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
  816. diff --git a/memchr.rs b/memchr.rs
  817. index 03f55f7..f767e0c 100644
  818. --- a/memchr.rs
  819. +++ b/memchr.rs
  820. @@ -11,103 +11,12 @@
  821. // Original implementation taken from rust-memchr
  822. // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch
  823. -
  824. -
  825. -/// A safe interface to `memchr`.
  826. -///
  827. -/// Returns the index corresponding to the first occurrence of `needle` in
  828. -/// `haystack`, or `None` if one is not found.
  829. -///
  830. -/// memchr reduces to super-optimized machine code at around an order of
  831. -/// magnitude faster than `haystack.iter().position(|&b| b == needle)`.
  832. -/// (See benchmarks.)
  833. -///
  834. -/// # Example
  835. -///
  836. -/// This shows how to find the first position of a byte in a byte string.
  837. -///
  838. -/// ```rust,ignore
  839. -/// use memchr::memchr;
  840. -///
  841. -/// let haystack = b"the quick brown fox";
  842. -/// assert_eq!(memchr(b'k', haystack), Some(8));
  843. -/// ```
  844. -pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
  845. - // libc memchr
  846. - #[cfg(not(target_os = "windows"))]
  847. - fn memchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> {
  848. - use libc;
  849. -
  850. - let p = unsafe {
  851. - libc::memchr(
  852. - haystack.as_ptr() as *const libc::c_void,
  853. - needle as libc::c_int,
  854. - haystack.len() as libc::size_t)
  855. - };
  856. - if p.is_null() {
  857. - None
  858. - } else {
  859. - Some(p as usize - (haystack.as_ptr() as usize))
  860. - }
  861. - }
  862. -
  863. - // use fallback on windows, since it's faster
  864. - #[cfg(target_os = "windows")]
  865. - fn memchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> {
  866. - fallback::memchr(needle, haystack)
  867. - }
  868. -
  869. - memchr_specific(needle, haystack)
  870. -}
  871. -
  872. -/// A safe interface to `memrchr`.
  873. -///
  874. -/// Returns the index corresponding to the last occurrence of `needle` in
  875. -/// `haystack`, or `None` if one is not found.
  876. -///
  877. -/// # Example
  878. -///
  879. -/// This shows how to find the last position of a byte in a byte string.
  880. -///
  881. -/// ```rust,ignore
  882. -/// use memchr::memrchr;
  883. -///
  884. -/// let haystack = b"the quick brown fox";
  885. -/// assert_eq!(memrchr(b'o', haystack), Some(17));
  886. -/// ```
  887. -pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
  888. -
  889. - #[cfg(target_os = "linux")]
  890. - fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> {
  891. - use libc;
  892. -
  893. - // GNU's memrchr() will - unlike memchr() - error if haystack is empty.
  894. - if haystack.is_empty() {return None}
  895. - let p = unsafe {
  896. - libc::memrchr(
  897. - haystack.as_ptr() as *const libc::c_void,
  898. - needle as libc::c_int,
  899. - haystack.len() as libc::size_t)
  900. - };
  901. - if p.is_null() {
  902. - None
  903. - } else {
  904. - Some(p as usize - (haystack.as_ptr() as usize))
  905. - }
  906. - }
  907. -
  908. - #[cfg(not(target_os = "linux"))]
  909. - fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> {
  910. - fallback::memrchr(needle, haystack)
  911. - }
  912. -
  913. - memrchr_specific(needle, haystack)
  914. -}
  915. +pub use self::fallback::{memchr,memrchr};
  916. #[allow(dead_code)]
  917. mod fallback {
  918. - use cmp;
  919. - use mem;
  920. + use core::cmp;
  921. + use core::mem;
  922. const LO_U64: u64 = 0x0101010101010101;
  923. const HI_U64: u64 = 0x8080808080808080;
  924. diff --git a/mod.rs b/mod.rs
  925. index 06609cf..106cf67 100644
  926. --- a/mod.rs
  927. +++ b/mod.rs
  928. @@ -247,42 +247,32 @@
  929. //! contract. The implementation of many of these functions are subject to change over
  930. //! time and may call fewer or more syscalls/library functions.
  931. -#![stable(feature = "rust1", since = "1.0.0")]
  932. -
  933. -use cmp;
  934. +use core::cmp;
  935. use rustc_unicode::str as core_str;
  936. -use error as std_error;
  937. -use fmt;
  938. -use result;
  939. -use str;
  940. -use memchr;
  941. -
  942. -#[stable(feature = "rust1", since = "1.0.0")]
  943. -pub use self::buffered::{BufReader, BufWriter, LineWriter};
  944. -#[stable(feature = "rust1", since = "1.0.0")]
  945. -pub use self::buffered::IntoInnerError;
  946. -#[stable(feature = "rust1", since = "1.0.0")]
  947. +use core::fmt;
  948. +use core::iter::{Iterator};
  949. +use core::marker::Sized;
  950. +#[cfg(feature="collections")] use core::ops::{Drop, FnOnce};
  951. +use core::option::Option::{self, Some, None};
  952. +use core::result::Result::{Ok, Err};
  953. +use core::result;
  954. +#[cfg(feature="collections")] use collections::string::String;
  955. +use core::str;
  956. +#[cfg(feature="collections")] use collections::vec::Vec;
  957. +mod memchr;
  958. +
  959. +#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter};
  960. +#[cfg(feature="collections")] pub use self::buffered::IntoInnerError;
  961. pub use self::cursor::Cursor;
  962. -#[stable(feature = "rust1", since = "1.0.0")]
  963. pub use self::error::{Result, Error, ErrorKind};
  964. -#[stable(feature = "rust1", since = "1.0.0")]
  965. pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat};
  966. -#[stable(feature = "rust1", since = "1.0.0")]
  967. -pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr};
  968. -#[stable(feature = "rust1", since = "1.0.0")]
  969. -pub use self::stdio::{StdoutLock, StderrLock, StdinLock};
  970. -#[unstable(feature = "libstd_io_internals", issue = "0")]
  971. -#[doc(no_inline, hidden)]
  972. -pub use self::stdio::{set_panic, set_print};
  973. pub mod prelude;
  974. -mod buffered;
  975. +#[cfg(feature="collections")] mod buffered;
  976. mod cursor;
  977. mod error;
  978. mod impls;
  979. -mod lazy;
  980. mod util;
  981. -mod stdio;
  982. const DEFAULT_BUF_SIZE: usize = 8 * 1024;
  983. @@ -304,6 +294,7 @@ const DEFAULT_BUF_SIZE: usize = 8 * 1024;
  984. // 2. We're passing a raw buffer to the function `f`, and it is expected that
  985. // the function only *appends* bytes to the buffer. We'll get undefined
  986. // behavior if existing bytes are overwritten to have non-UTF-8 data.
  987. +#[cfg(feature="collections")]
  988. fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
  989. where F: FnOnce(&mut Vec<u8>) -> Result<usize>
  990. {
  991. @@ -335,6 +326,7 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
  992. // of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every
  993. // time is 4,500 times (!) slower than this if the reader has a very small
  994. // amount of data to return.
  995. +#[cfg(feature="collections")]
  996. fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> {
  997. let start_len = buf.len();
  998. let mut len = start_len;
  999. @@ -417,7 +409,6 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
  1000. /// # Ok(())
  1001. /// # }
  1002. /// ```
  1003. -#[stable(feature = "rust1", since = "1.0.0")]
  1004. pub trait Read {
  1005. /// Pull some bytes from this source into the specified buffer, returning
  1006. /// how many bytes were read.
  1007. @@ -467,7 +458,6 @@ pub trait Read {
  1008. /// # Ok(())
  1009. /// # }
  1010. /// ```
  1011. - #[stable(feature = "rust1", since = "1.0.0")]
  1012. fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
  1013. /// Read all bytes until EOF in this source, placing them into `buf`.
  1014. @@ -509,7 +499,7 @@ pub trait Read {
  1015. /// # Ok(())
  1016. /// # }
  1017. /// ```
  1018. - #[stable(feature = "rust1", since = "1.0.0")]
  1019. + #[cfg(feature="collections")]
  1020. fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
  1021. read_to_end(self, buf)
  1022. }
  1023. @@ -547,7 +537,7 @@ pub trait Read {
  1024. /// # Ok(())
  1025. /// # }
  1026. /// ```
  1027. - #[stable(feature = "rust1", since = "1.0.0")]
  1028. + #[cfg(feature="collections")]
  1029. fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
  1030. // Note that we do *not* call `.read_to_end()` here. We are passing
  1031. // `&mut Vec<u8>` (the raw contents of `buf`) into the `read_to_end`
  1032. @@ -608,7 +598,6 @@ pub trait Read {
  1033. /// # Ok(())
  1034. /// # }
  1035. /// ```
  1036. - #[stable(feature = "read_exact", since = "1.6.0")]
  1037. fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> {
  1038. while !buf.is_empty() {
  1039. match self.read(buf) {
  1040. @@ -660,7 +649,6 @@ pub trait Read {
  1041. /// # Ok(())
  1042. /// # }
  1043. /// ```
  1044. - #[stable(feature = "rust1", since = "1.0.0")]
  1045. fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
  1046. /// Transforms this `Read` instance to an `Iterator` over its bytes.
  1047. @@ -690,7 +678,6 @@ pub trait Read {
  1048. /// # Ok(())
  1049. /// # }
  1050. /// ```
  1051. - #[stable(feature = "rust1", since = "1.0.0")]
  1052. fn bytes(self) -> Bytes<Self> where Self: Sized {
  1053. Bytes { inner: self }
  1054. }
  1055. @@ -727,10 +714,6 @@ pub trait Read {
  1056. /// # Ok(())
  1057. /// # }
  1058. /// ```
  1059. - #[unstable(feature = "io", reason = "the semantics of a partial read/write \
  1060. - of where errors happen is currently \
  1061. - unclear and may change",
  1062. - issue = "27802")]
  1063. fn chars(self) -> Chars<Self> where Self: Sized {
  1064. Chars { inner: self }
  1065. }
  1066. @@ -765,7 +748,6 @@ pub trait Read {
  1067. /// # Ok(())
  1068. /// # }
  1069. /// ```
  1070. - #[stable(feature = "rust1", since = "1.0.0")]
  1071. fn chain<R: Read>(self, next: R) -> Chain<Self, R> where Self: Sized {
  1072. Chain { first: self, second: next, done_first: false }
  1073. }
  1074. @@ -799,7 +781,6 @@ pub trait Read {
  1075. /// # Ok(())
  1076. /// # }
  1077. /// ```
  1078. - #[stable(feature = "rust1", since = "1.0.0")]
  1079. fn take(self, limit: u64) -> Take<Self> where Self: Sized {
  1080. Take { inner: self, limit: limit }
  1081. }
  1082. @@ -835,7 +816,6 @@ pub trait Read {
  1083. /// # Ok(())
  1084. /// # }
  1085. /// ```
  1086. -#[stable(feature = "rust1", since = "1.0.0")]
  1087. pub trait Write {
  1088. /// Write a buffer into this object, returning how many bytes were written.
  1089. ///
  1090. @@ -875,7 +855,6 @@ pub trait Write {
  1091. /// # Ok(())
  1092. /// # }
  1093. /// ```
  1094. - #[stable(feature = "rust1", since = "1.0.0")]
  1095. fn write(&mut self, buf: &[u8]) -> Result<usize>;
  1096. /// Flush this output stream, ensuring that all intermediately buffered
  1097. @@ -901,7 +880,6 @@ pub trait Write {
  1098. /// # Ok(())
  1099. /// # }
  1100. /// ```
  1101. - #[stable(feature = "rust1", since = "1.0.0")]
  1102. fn flush(&mut self) -> Result<()>;
  1103. /// Attempts to write an entire buffer into this write.
  1104. @@ -928,7 +906,6 @@ pub trait Write {
  1105. /// # Ok(())
  1106. /// # }
  1107. /// ```
  1108. - #[stable(feature = "rust1", since = "1.0.0")]
  1109. fn write_all(&mut self, mut buf: &[u8]) -> Result<()> {
  1110. while !buf.is_empty() {
  1111. match self.write(buf) {
  1112. @@ -980,7 +957,6 @@ pub trait Write {
  1113. /// # Ok(())
  1114. /// # }
  1115. /// ```
  1116. - #[stable(feature = "rust1", since = "1.0.0")]
  1117. fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> {
  1118. // Create a shim which translates a Write to a fmt::Write and saves
  1119. // off I/O errors. instead of discarding them
  1120. @@ -1036,7 +1012,6 @@ pub trait Write {
  1121. /// # Ok(())
  1122. /// # }
  1123. /// ```
  1124. - #[stable(feature = "rust1", since = "1.0.0")]
  1125. fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
  1126. }
  1127. @@ -1066,7 +1041,6 @@ pub trait Write {
  1128. /// # Ok(())
  1129. /// # }
  1130. /// ```
  1131. -#[stable(feature = "rust1", since = "1.0.0")]
  1132. pub trait Seek {
  1133. /// Seek to an offset, in bytes, in a stream.
  1134. ///
  1135. @@ -1082,7 +1056,6 @@ pub trait Seek {
  1136. /// Seeking to a negative offset is considered an error.
  1137. ///
  1138. /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start
  1139. - #[stable(feature = "rust1", since = "1.0.0")]
  1140. fn seek(&mut self, pos: SeekFrom) -> Result<u64>;
  1141. }
  1142. @@ -1092,29 +1065,26 @@ pub trait Seek {
  1143. ///
  1144. /// [`Seek`]: trait.Seek.html
  1145. #[derive(Copy, PartialEq, Eq, Clone, Debug)]
  1146. -#[stable(feature = "rust1", since = "1.0.0")]
  1147. pub enum SeekFrom {
  1148. /// Set the offset to the provided number of bytes.
  1149. - #[stable(feature = "rust1", since = "1.0.0")]
  1150. - Start(#[stable(feature = "rust1", since = "1.0.0")] u64),
  1151. + Start(u64),
  1152. /// Set the offset to the size of this object plus the specified number of
  1153. /// bytes.
  1154. ///
  1155. /// It is possible to seek beyond the end of an object, but it's an error to
  1156. /// seek before byte 0.
  1157. - #[stable(feature = "rust1", since = "1.0.0")]
  1158. - End(#[stable(feature = "rust1", since = "1.0.0")] i64),
  1159. + End(i64),
  1160. /// Set the offset to the current position plus the specified number of
  1161. /// bytes.
  1162. ///
  1163. /// It is possible to seek beyond the end of an object, but it's an error to
  1164. /// seek before byte 0.
  1165. - #[stable(feature = "rust1", since = "1.0.0")]
  1166. - Current(#[stable(feature = "rust1", since = "1.0.0")] i64),
  1167. + Current(i64),
  1168. }
  1169. +#[cfg(feature="collections")]
  1170. fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
  1171. -> Result<usize> {
  1172. let mut read = 0;
  1173. @@ -1194,7 +1164,7 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
  1174. /// # }
  1175. /// ```
  1176. ///
  1177. -#[stable(feature = "rust1", since = "1.0.0")]
  1178. +#[cfg(feature="collections")]
  1179. pub trait BufRead: Read {
  1180. /// Fills the internal buffer of this object, returning the buffer contents.
  1181. ///
  1182. @@ -1239,7 +1209,6 @@ pub trait BufRead: Read {
  1183. /// // ensure the bytes we worked with aren't returned again later
  1184. /// stdin.consume(length);
  1185. /// ```
  1186. - #[stable(feature = "rust1", since = "1.0.0")]
  1187. fn fill_buf(&mut self) -> Result<&[u8]>;
  1188. /// Tells this buffer that `amt` bytes have been consumed from the buffer,
  1189. @@ -1261,7 +1230,6 @@ pub trait BufRead: Read {
  1190. ///
  1191. /// Since `consume()` is meant to be used with [`fill_buf()`][fillbuf],
  1192. /// that method's example includes an example of `consume()`.
  1193. - #[stable(feature = "rust1", since = "1.0.0")]
  1194. fn consume(&mut self, amt: usize);
  1195. /// Read all bytes into `buf` until the delimiter `byte` is reached.
  1196. @@ -1302,7 +1270,6 @@ pub trait BufRead: Read {
  1197. /// # Ok(())
  1198. /// # }
  1199. /// ```
  1200. - #[stable(feature = "rust1", since = "1.0.0")]
  1201. fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize> {
  1202. read_until(self, byte, buf)
  1203. }
  1204. @@ -1350,7 +1317,6 @@ pub trait BufRead: Read {
  1205. /// buffer.clear();
  1206. /// }
  1207. /// ```
  1208. - #[stable(feature = "rust1", since = "1.0.0")]
  1209. fn read_line(&mut self, buf: &mut String) -> Result<usize> {
  1210. // Note that we are not calling the `.read_until` method here, but
  1211. // rather our hardcoded implementation. For more details as to why, see
  1212. @@ -1383,7 +1349,6 @@ pub trait BufRead: Read {
  1213. /// println!("{:?}", content.unwrap());
  1214. /// }
  1215. /// ```
  1216. - #[stable(feature = "rust1", since = "1.0.0")]
  1217. fn split(self, byte: u8) -> Split<Self> where Self: Sized {
  1218. Split { buf: self, delim: byte }
  1219. }
  1220. @@ -1408,7 +1373,6 @@ pub trait BufRead: Read {
  1221. /// println!("{}", line.unwrap());
  1222. /// }
  1223. /// ```
  1224. - #[stable(feature = "rust1", since = "1.0.0")]
  1225. fn lines(self) -> Lines<Self> where Self: Sized {
  1226. Lines { buf: self }
  1227. }
  1228. @@ -1420,14 +1384,12 @@ pub trait BufRead: Read {
  1229. /// Please see the documentation of `chain()` for more details.
  1230. ///
  1231. /// [chain]: trait.Read.html#method.chain
  1232. -#[stable(feature = "rust1", since = "1.0.0")]
  1233. pub struct Chain<T, U> {
  1234. first: T,
  1235. second: U,
  1236. done_first: bool,
  1237. }
  1238. -#[stable(feature = "rust1", since = "1.0.0")]
  1239. impl<T: Read, U: Read> Read for Chain<T, U> {
  1240. fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
  1241. if !self.done_first {
  1242. @@ -1440,7 +1402,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
  1243. }
  1244. }
  1245. -#[stable(feature = "chain_bufread", since = "1.9.0")]
  1246. +#[cfg(feature="collections")]
  1247. impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
  1248. fn fill_buf(&mut self) -> Result<&[u8]> {
  1249. if !self.done_first {
  1250. @@ -1467,7 +1429,6 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
  1251. /// Please see the documentation of `take()` for more details.
  1252. ///
  1253. /// [take]: trait.Read.html#method.take
  1254. -#[stable(feature = "rust1", since = "1.0.0")]
  1255. pub struct Take<T> {
  1256. inner: T,
  1257. limit: u64,
  1258. @@ -1499,7 +1460,6 @@ impl<T> Take<T> {
  1259. /// # Ok(())
  1260. /// # }
  1261. /// ```
  1262. - #[stable(feature = "rust1", since = "1.0.0")]
  1263. pub fn limit(&self) -> u64 { self.limit }
  1264. /// Consumes the `Take`, returning the wrapped reader.
  1265. @@ -1524,13 +1484,11 @@ impl<T> Take<T> {
  1266. /// # Ok(())
  1267. /// # }
  1268. /// ```
  1269. - #[unstable(feature = "io_take_into_inner", issue = "0")]
  1270. pub fn into_inner(self) -> T {
  1271. self.inner
  1272. }
  1273. }
  1274. -#[stable(feature = "rust1", since = "1.0.0")]
  1275. impl<T: Read> Read for Take<T> {
  1276. fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
  1277. // Don't call into inner reader at all at EOF because it may still block
  1278. @@ -1545,7 +1503,7 @@ impl<T: Read> Read for Take<T> {
  1279. }
  1280. }
  1281. -#[stable(feature = "rust1", since = "1.0.0")]
  1282. +#[cfg(feature="collections")]
  1283. impl<T: BufRead> BufRead for Take<T> {
  1284. fn fill_buf(&mut self) -> Result<&[u8]> {
  1285. // Don't call into inner reader at all at EOF because it may still block
  1286. @@ -1584,12 +1542,10 @@ fn read_one_byte(reader: &mut Read) -> Option<Result<u8>> {
  1287. /// Please see the documentation of `bytes()` for more details.
  1288. ///
  1289. /// [bytes]: trait.Read.html#method.bytes
  1290. -#[stable(feature = "rust1", since = "1.0.0")]
  1291. pub struct Bytes<R> {
  1292. inner: R,
  1293. }
  1294. -#[stable(feature = "rust1", since = "1.0.0")]
  1295. impl<R: Read> Iterator for Bytes<R> {
  1296. type Item = Result<u8>;
  1297. @@ -1604,8 +1560,6 @@ impl<R: Read> Iterator for Bytes<R> {
  1298. /// Please see the documentation of `chars()` for more details.
  1299. ///
  1300. /// [chars]: trait.Read.html#method.chars
  1301. -#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
  1302. - issue = "27802")]
  1303. pub struct Chars<R> {
  1304. inner: R,
  1305. }
  1306. @@ -1613,8 +1567,6 @@ pub struct Chars<R> {
  1307. /// An enumeration of possible errors that can be generated from the `Chars`
  1308. /// adapter.
  1309. #[derive(Debug)]
  1310. -#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
  1311. - issue = "27802")]
  1312. pub enum CharsError {
  1313. /// Variant representing that the underlying stream was read successfully
  1314. /// but it did not contain valid utf8 data.
  1315. @@ -1624,8 +1576,6 @@ pub enum CharsError {
  1316. Other(Error),
  1317. }
  1318. -#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
  1319. - issue = "27802")]
  1320. impl<R: Read> Iterator for Chars<R> {
  1321. type Item = result::Result<char, CharsError>;
  1322. @@ -1657,25 +1607,6 @@ impl<R: Read> Iterator for Chars<R> {
  1323. }
  1324. }
  1325. -#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
  1326. - issue = "27802")]
  1327. -impl std_error::Error for CharsError {
  1328. - fn description(&self) -> &str {
  1329. - match *self {
  1330. - CharsError::NotUtf8 => "invalid utf8 encoding",
  1331. - CharsError::Other(ref e) => std_error::Error::description(e),
  1332. - }
  1333. - }
  1334. - fn cause(&self) -> Option<&std_error::Error> {
  1335. - match *self {
  1336. - CharsError::NotUtf8 => None,
  1337. - CharsError::Other(ref e) => e.cause(),
  1338. - }
  1339. - }
  1340. -}
  1341. -
  1342. -#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
  1343. - issue = "27802")]
  1344. impl fmt::Display for CharsError {
  1345. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  1346. match *self {
  1347. @@ -1694,13 +1625,13 @@ impl fmt::Display for CharsError {
  1348. /// `BufRead`. Please see the documentation of `split()` for more details.
  1349. ///
  1350. /// [split]: trait.BufRead.html#method.split
  1351. -#[stable(feature = "rust1", since = "1.0.0")]
  1352. +#[cfg(feature="collections")]
  1353. pub struct Split<B> {
  1354. buf: B,
  1355. delim: u8,
  1356. }
  1357. -#[stable(feature = "rust1", since = "1.0.0")]
  1358. +#[cfg(feature="collections")]
  1359. impl<B: BufRead> Iterator for Split<B> {
  1360. type Item = Result<Vec<u8>>;
  1361. @@ -1725,12 +1656,12 @@ impl<B: BufRead> Iterator for Split<B> {
  1362. /// `BufRead`. Please see the documentation of `lines()` for more details.
  1363. ///
  1364. /// [lines]: trait.BufRead.html#method.lines
  1365. -#[stable(feature = "rust1", since = "1.0.0")]
  1366. +#[cfg(feature="collections")]
  1367. pub struct Lines<B> {
  1368. buf: B,
  1369. }
  1370. -#[stable(feature = "rust1", since = "1.0.0")]
  1371. +#[cfg(feature="collections")]
  1372. impl<B: BufRead> Iterator for Lines<B> {
  1373. type Item = Result<String>;
  1374. diff --git a/prelude.rs b/prelude.rs
  1375. index 8772d0f..49d66c9 100644
  1376. --- a/prelude.rs
  1377. +++ b/prelude.rs
  1378. @@ -18,7 +18,8 @@
  1379. //! use std::io::prelude::*;
  1380. //! ```
  1381. -#![stable(feature = "rust1", since = "1.0.0")]
  1382. +pub use super::{Read, Write, Seek};
  1383. +#[cfg(feature="collections")] pub use super::BufRead;
  1384. -#[stable(feature = "rust1", since = "1.0.0")]
  1385. -pub use super::{Read, Write, BufRead, Seek};
  1386. +#[cfg(feature="collections")] pub use alloc::boxed::Box;
  1387. +#[cfg(feature="collections")] pub use collections::vec::Vec;
  1388. diff --git a/util.rs b/util.rs
  1389. index 2c68802..93bcfc3 100644
  1390. --- a/util.rs
  1391. +++ b/util.rs
  1392. @@ -10,7 +10,8 @@
  1393. #![allow(missing_copy_implementations)]
  1394. -use io::{self, Read, Write, ErrorKind, BufRead};
  1395. +use io::{self, Read, Write, ErrorKind};
  1396. +#[cfg(feature="collections")] use io::BufRead;
  1397. /// Copies the entire contents of a reader into a writer.
  1398. ///
  1399. @@ -42,7 +43,6 @@ use io::{self, Read, Write, ErrorKind, BufRead};
  1400. /// # Ok(())
  1401. /// # }
  1402. /// ```
  1403. -#[stable(feature = "rust1", since = "1.0.0")]
  1404. pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64>
  1405. where R: Read, W: Write
  1406. {
  1407. @@ -66,7 +66,6 @@ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<
  1408. /// the documentation of `empty()` for more details.
  1409. ///
  1410. /// [empty]: fn.empty.html
  1411. -#[stable(feature = "rust1", since = "1.0.0")]
  1412. pub struct Empty { _priv: () }
  1413. /// Constructs a new handle to an empty reader.
  1414. @@ -84,14 +83,12 @@ pub struct Empty { _priv: () }
  1415. /// io::empty().read_to_string(&mut buffer).unwrap();
  1416. /// assert!(buffer.is_empty());
  1417. /// ```
  1418. -#[stable(feature = "rust1", since = "1.0.0")]
  1419. pub fn empty() -> Empty { Empty { _priv: () } }
  1420. -#[stable(feature = "rust1", since = "1.0.0")]
  1421. impl Read for Empty {
  1422. fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> { Ok(0) }
  1423. }
  1424. -#[stable(feature = "rust1", since = "1.0.0")]
  1425. +#[cfg(feature="collections")]
  1426. impl BufRead for Empty {
  1427. fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) }
  1428. fn consume(&mut self, _n: usize) {}
  1429. @@ -103,7 +100,6 @@ impl BufRead for Empty {
  1430. /// see the documentation of `repeat()` for more details.
  1431. ///
  1432. /// [repeat]: fn.repeat.html
  1433. -#[stable(feature = "rust1", since = "1.0.0")]
  1434. pub struct Repeat { byte: u8 }
  1435. /// Creates an instance of a reader that infinitely repeats one byte.
  1436. @@ -120,10 +116,8 @@ pub struct Repeat { byte: u8 }
  1437. /// io::repeat(0b101).read_exact(&mut buffer).unwrap();
  1438. /// assert_eq!(buffer, [0b101, 0b101, 0b101]);
  1439. /// ```
  1440. -#[stable(feature = "rust1", since = "1.0.0")]
  1441. pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } }
  1442. -#[stable(feature = "rust1", since = "1.0.0")]
  1443. impl Read for Repeat {
  1444. fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
  1445. for slot in &mut *buf {
  1446. @@ -139,7 +133,6 @@ impl Read for Repeat {
  1447. /// see the documentation of `sink()` for more details.
  1448. ///
  1449. /// [sink]: fn.sink.html
  1450. -#[stable(feature = "rust1", since = "1.0.0")]
  1451. pub struct Sink { _priv: () }
  1452. /// Creates an instance of a writer which will successfully consume all data.
  1453. @@ -156,10 +149,8 @@ pub struct Sink { _priv: () }
  1454. /// let num_bytes = io::sink().write(&buffer).unwrap();
  1455. /// assert_eq!(num_bytes, 5);
  1456. /// ```
  1457. -#[stable(feature = "rust1", since = "1.0.0")]
  1458. pub fn sink() -> Sink { Sink { _priv: () } }
  1459. -#[stable(feature = "rust1", since = "1.0.0")]
  1460. impl Write for Sink {
  1461. fn write(&mut self, buf: &[u8]) -> io::Result<usize> { Ok(buf.len()) }
  1462. fn flush(&mut self) -> io::Result<()> { Ok(()) }