diff options
| author | bors <bors@rust-lang.org> | 2014-09-26 21:47:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-09-26 21:47:47 +0000 |
| commit | d64b4103d688f38c2e9e2daf966d50beeb383f1e (patch) | |
| tree | 5242f7c1eae334e68e7709667a0f63b850e9beaf /src/libstd | |
| parent | 5d653c17a656e8fe1572c7a695e33b188eda0597 (diff) | |
| parent | 21df9c805f6e0101cff7a04391c6c5fcff8056df (diff) | |
| download | rust-d64b4103d688f38c2e9e2daf966d50beeb383f1e.tar.gz rust-d64b4103d688f38c2e9e2daf966d50beeb383f1e.zip | |
auto merge of #17464 : pcwalton/rust/inherent-methods-on-equal-footing, r=nikomatsakis
over inherent methods accessible via more autoderefs.
This simplifies the trait matching algorithm. It breaks code like:
impl Foo {
fn foo(self) {
// before this change, this will be called
}
}
impl<'a,'b,'c> Trait for &'a &'b &'c Foo {
fn foo(self) {
// after this change, this will be called
}
}
fn main() {
let x = &(&(&Foo));
x.foo();
}
To explicitly indicate that you wish to call the inherent method, perform
explicit dereferences. For example:
fn main() {
let x = &(&(&Foo));
(***x).foo();
}
Part of #17282.
[breaking-change]
r? @nikomatsakis
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/mod.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index ff508c802d8..81e05648567 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -946,11 +946,14 @@ pub trait Reader { } impl<'a> Reader for Box<Reader+'a> { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) } + fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + let reader: &mut Reader = &mut **self; + reader.read(buf) + } } impl<'a> Reader for &'a mut Reader+'a { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) } + fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { (*self).read(buf) } } /// Returns a slice of `v` between `start` and `end`. @@ -1281,10 +1284,14 @@ pub trait Writer { impl<'a> Writer for Box<Writer+'a> { #[inline] - fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) } + fn write(&mut self, buf: &[u8]) -> IoResult<()> { + (&mut **self).write(buf) + } #[inline] - fn flush(&mut self) -> IoResult<()> { self.flush() } + fn flush(&mut self) -> IoResult<()> { + (&mut **self).flush() + } } impl<'a> Writer for &'a mut Writer+'a { |
