diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-01-01 14:53:20 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-01-02 12:19:59 -0500 |
| commit | 64b7c22c46b204520a6fae1c5cd750a3d3c6a66a (patch) | |
| tree | 6e9a504759c5ac42f747c5739b4173d6646cd8c8 /src/liballoc | |
| parent | d55577255434d1a9969b74cc4ac5dff4c04d6054 (diff) | |
| download | rust-64b7c22c46b204520a6fae1c5cd750a3d3c6a66a.tar.gz rust-64b7c22c46b204520a6fae1c5cd750a3d3c6a66a.zip | |
core: use assoc types in `Deref[Mut]`
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 4 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 1 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 4 |
4 files changed, 12 insertions, 5 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 820a3838978..d38b77eb6fd 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -247,7 +247,9 @@ impl<T> BorrowFrom<Arc<T>> for T { } #[experimental = "Deref is experimental."] -impl<T> Deref<T> for Arc<T> { +impl<T> Deref for Arc<T> { + type Target = T; + #[inline] fn deref(&self) -> &T { &self.inner().data diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 74f0599e486..0d6ada4b229 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -153,11 +153,13 @@ impl fmt::Show for Box<Any+'static> { } } -impl<Sized? T> Deref<T> for Box<T> { +impl<Sized? T> Deref for Box<T> { + type Target = T; + fn deref(&self) -> &T { &**self } } -impl<Sized? T> DerefMut<T> for Box<T> { +impl<Sized? T> DerefMut for Box<T> { fn deref_mut(&mut self) -> &mut T { &mut **self } } @@ -210,7 +212,7 @@ mod test { #[test] fn deref() { - fn homura<T: Deref<i32>>(_: T) { } + fn homura<T: Deref<Target=i32>>(_: T) { } homura(box 765i32); } } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 61b5d43d1cb..c4858aea022 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -65,6 +65,7 @@ #![no_std] #![feature(lang_items, phase, unsafe_destructor, default_type_params)] +#![feature(associated_types)] #[phase(plugin, link)] extern crate core; diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index bd250938836..c57231fc434 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -355,7 +355,9 @@ impl<T> BorrowFrom<Rc<T>> for T { } #[experimental = "Deref is experimental."] -impl<T> Deref<T> for Rc<T> { +impl<T> Deref for Rc<T> { + type Target = T; + #[inline(always)] fn deref(&self) -> &T { &self.inner().value |
