You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct Foo { x: int }
impl io::Reader for Foo {
fn read(&self, _bytes: &mut [u8], _len: uint) -> uint { fail!() }
fn read_byte(&self) -> int { fail!() }
fn eof(&self) -> bool { fail!() }
fn seek(&self, _position: int, _style: io::SeekStyle) { fail!() }
fn tell(&self) -> uint { fail!() }
}
impl Foo {
fn bar(&mut self) {
self.read_be_u32(); // read_be_u32 is defined by io::ReaderUtil, which is defined for all <T: io::Reader>
}
}
fn main() {}
rustc fails with this error:
test-impl-for-t.rs:15:12: 15:31 error: failed to find an implementation of trait core::io::Reader for &mut Foo
test-impl-for-t.rs:15 self.read_be_u32();
^~~~~~~~~~~~~~~~~~~
I don't think that rustc should have a problem with this code.
Note that this error seems to be related to &mut pointers and immutable borrows, because if the bar function is changed to the following then rustc is happy: