about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-26 17:37:29 -0700
committerbors <bors@rust-lang.org>2013-06-26 17:37:29 -0700
commit36d7f601d8d419ace8fdf14b2014a9cbf6245896 (patch)
tree47f511bde18a704513fb3b6b74f4b4b434c3cd73 /src/libstd
parent32adc0e730636f04d72d31e24fbf1101a495ccb7 (diff)
parentc37ccac9313b52a8f4299b370fe33b0fbe202db4 (diff)
downloadrust-36d7f601d8d419ace8fdf14b2014a9cbf6245896.tar.gz
rust-36d7f601d8d419ace8fdf14b2014a9cbf6245896.zip
auto merge of #7354 : bblum/rust/trait-bounds, r=pcwalton
r? @nikomatsakis
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libstd/io.rs b/src/libstd/io.rs
index 71a0dd6b9b2..a78be9c8b2b 100644
--- a/src/libstd/io.rs
+++ b/src/libstd/io.rs
@@ -1042,12 +1042,14 @@ pub fn file_reader(path: &Path) -> Result<@Reader, ~str> {
 
 
 // Byte readers
-pub struct BytesReader<'self> {
-    bytes: &'self [u8],
+pub struct BytesReader {
+    // FIXME(#5723) see other FIXME below
+    // FIXME(#7268) this should also be parameterized over <'self>
+    bytes: &'static [u8],
     pos: @mut uint
 }
 
-impl<'self> Reader for BytesReader<'self> {
+impl Reader for BytesReader {
     fn read(&self, bytes: &mut [u8], len: uint) -> uint {
         let count = uint::min(len, self.bytes.len() - *self.pos);
 
@@ -1084,6 +1086,10 @@ impl<'self> Reader for BytesReader<'self> {
 }
 
 pub fn with_bytes_reader<T>(bytes: &[u8], f: &fn(@Reader) -> T) -> T {
+    // XXX XXX XXX this is glaringly unsound
+    // FIXME(#5723) Use a &Reader for the callback's argument. Should be:
+    // fn with_bytes_reader<'r, T>(bytes: &'r [u8], f: &fn(&'r Reader) -> T) -> T
+    let bytes: &'static [u8] = unsafe { cast::transmute(bytes) };
     f(@BytesReader {
         bytes: bytes,
         pos: @mut 0
@@ -1091,6 +1097,7 @@ pub fn with_bytes_reader<T>(bytes: &[u8], f: &fn(@Reader) -> T) -> T {
 }
 
 pub fn with_str_reader<T>(s: &str, f: &fn(@Reader) -> T) -> T {
+    // FIXME(#5723): As above.
     with_bytes_reader(s.as_bytes(), f)
 }