about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcore/io.rs17
-rw-r--r--src/libstd/json.rs2
-rw-r--r--src/libstd/time.rs2
-rw-r--r--src/libsyntax/parse/comments.rs1
-rw-r--r--src/rustc/driver/rustc.rs1
5 files changed, 17 insertions, 6 deletions
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index 021aa624e06..97039800fb6 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -48,6 +48,17 @@ trait Reader {
 trait ReaderUtil {
     fn read_bytes(len: uint) -> ~[u8];
     fn read_line() -> ~str;
+
+    fn read_chars(n: uint) -> ~[char];
+    fn read_char() -> char;
+    fn read_c_str() -> ~str;
+    fn read_le_uint(size: uint) -> uint;
+    fn read_le_int(size: uint) -> int;
+    fn read_be_uint(size: uint) -> uint;
+    fn read_whole_stream() -> ~[u8];
+    fn each_byte(it: fn(int) -> bool);
+    fn each_char(it: fn(char) -> bool);
+    fn each_line(it: fn((&str)) -> bool);
 }
 
 impl<T: Reader> T : ReaderUtil {
@@ -69,12 +80,10 @@ impl<T: Reader> T : ReaderUtil {
         }
         str::from_bytes(buf)
     }
-}
 
-impl Reader {
     fn read_chars(n: uint) -> ~[char] {
         // returns the (consumed offset, n_req), appends characters to &chars
-        fn chars_from_bytes(buf: &~[u8], chars: &mut ~[char])
+        fn chars_from_bytes<T: Reader>(buf: &~[u8], chars: &mut ~[char])
             -> (uint, uint) {
             let mut i = 0;
             let buf_len = buf.len();
@@ -120,7 +129,7 @@ impl Reader {
                 break;
             }
             vec::push_all(buf, data);
-            let (offset, nbreq) = chars_from_bytes(&buf, &mut chars);
+            let (offset, nbreq) = chars_from_bytes::<T>(&buf, &mut chars);
             let ncreq = n - chars.len();
             // again we either know we need a certain number of bytes
             // to complete a character, or we make sure we don't
diff --git a/src/libstd/json.rs b/src/libstd/json.rs
index db22b9ff30b..00e09f6604d 100644
--- a/src/libstd/json.rs
+++ b/src/libstd/json.rs
@@ -8,7 +8,7 @@
 
 use core::cmp::{Eq, Ord};
 use result::{Result, Ok, Err};
-use io::WriterUtil;
+use io::{WriterUtil, ReaderUtil};
 use map::HashMap;
 use map::Map;
 use sort::Sort;
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index 64f65d15a93..890a7a0b468 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -3,7 +3,7 @@
 
 use core::cmp::Eq;
 use libc::{c_char, c_int, c_long, size_t, time_t};
-use io::Reader;
+use io::{Reader, ReaderUtil};
 use result::{Result, Ok, Err};
 
 export
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 9c705cff7bb..ddc70a1f13e 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -1,4 +1,5 @@
 use io::println;//XXXXXXXXxxx
+use io::ReaderUtil;
 use util::interner;
 use lexer::{string_reader, bump, is_eof, nextch,
                is_whitespace, get_str_from, reader};
diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs
index 0306d0dbb18..6ea5bb28023 100644
--- a/src/rustc/driver/rustc.rs
+++ b/src/rustc/driver/rustc.rs
@@ -12,6 +12,7 @@ use core::*;
 
 // -*- rust -*-
 use result::{Ok, Err};
+use io::ReaderUtil;
 use std::getopts;
 use std::map::HashMap;
 use getopts::{opt_present};