]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/io/mod.rs
auto merge of #15999 : Kimundi/rust/fix_folder, r=nikomatsakis
[rust.git] / src / libstd / io / mod.rs
index fe9016453f78eb726f9cf03d3dd3cd84c75bfc30..f1b92b973c8bb1649a0e404882f11dd878423831 100644 (file)
@@ -7,6 +7,8 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+//
+// ignore-lexer-test FIXME #15883
 
 // FIXME: cover these topics:
 //        path, reader, writer, stream, raii (close not needed),
@@ -221,6 +223,7 @@ fn file_product(p: &Path) -> IoResult<u32> {
 
 use char::Char;
 use collections::Collection;
+use default::Default;
 use fmt;
 use int;
 use iter::Iterator;
@@ -229,7 +232,7 @@ fn file_product(p: &Path) -> IoResult<u32> {
 use ops::{BitOr, BitAnd, Sub, Not};
 use option::{Option, Some, None};
 use os;
-use owned::Box;
+use boxed::Box;
 use result::{Ok, Err, Result};
 use rt::rtio;
 use slice::{Vector, MutableVector, ImmutableVector};
@@ -237,6 +240,7 @@ fn file_product(p: &Path) -> IoResult<u32> {
 use str;
 use string::String;
 use uint;
+use unicode::char::UnicodeChar;
 use vec::Vec;
 
 // Reexports
@@ -292,7 +296,7 @@ fn file_product(p: &Path) -> IoResult<u32> {
 /// # FIXME
 ///
 /// Is something like this sufficient? It's kind of archaic
-#[deriving(PartialEq, Clone)]
+#[deriving(PartialEq, Eq, Clone)]
 pub struct IoError {
     /// An enumeration which can be matched against for determining the flavor
     /// of error.
@@ -434,7 +438,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 }
 
 /// A list specifying general categories of I/O error.
-#[deriving(PartialEq, Clone, Show)]
+#[deriving(PartialEq, Eq, Clone, Show)]
 pub enum IoErrorKind {
     /// Any I/O error not part of this list.
     OtherIoError,
@@ -704,9 +708,9 @@ fn read_to_end(&mut self) -> IoResult<Vec<u8>> {
     /// UTF-8 bytes.
     fn read_to_string(&mut self) -> IoResult<String> {
         self.read_to_end().and_then(|s| {
-            match str::from_utf8(s.as_slice()) {
-                Some(s) => Ok(String::from_str(s)),
-                None => Err(standard_error(InvalidInput)),
+            match String::from_utf8(s) {
+                Ok(s)  => Ok(s),
+                Err(_) => Err(standard_error(InvalidInput)),
             }
         })
     }
@@ -1439,9 +1443,9 @@ pub trait Buffer: Reader {
     /// valid UTF-8 sequence of bytes.
     fn read_line(&mut self) -> IoResult<String> {
         self.read_until('\n' as u8).and_then(|line|
-            match str::from_utf8(line.as_slice()) {
-                Some(s) => Ok(String::from_str(s)),
-                None => Err(standard_error(InvalidInput)),
+            match String::from_utf8(line) {
+                Ok(s)  => Ok(s),
+                Err(_) => Err(standard_error(InvalidInput)),
             }
         )
     }
@@ -1792,7 +1796,6 @@ pub struct UnstableFileStat {
 bitflags!(
     #[doc="A set of permissions for a file or directory is represented
 by a set of flags which are or'd together."]
-    #[deriving(Hash)]
     #[deriving(Show)]
     flags FilePermission: u32 {
         static UserRead     = 0o400,
@@ -1827,6 +1830,11 @@ pub struct UnstableFileStat {
     }
 )
 
+impl Default for FilePermission {
+    #[inline]
+    fn default() -> FilePermission { FilePermission::empty() }
+}
+
 #[cfg(test)]
 mod tests {
     use super::{IoResult, Reader, MemReader, NoProgress, InvalidInput};