diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-03-20 22:10:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-03-22 08:48:34 -0700 |
| commit | 3fb1ed0e046e4208ea8a28f989d1b184143d62ce (patch) | |
| tree | d6fbeef71f581f189caba5d6d479d56e19f5cf8b /src/libstd | |
| parent | 76f0b1ad1fb314199b6db61df753d6757dee3b77 (diff) | |
| download | rust-3fb1ed0e046e4208ea8a28f989d1b184143d62ce.tar.gz rust-3fb1ed0e046e4208ea8a28f989d1b184143d62ce.zip | |
rustc: Remove all usage of manual deref()
Favor using '*' instead
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/hash/mod.rs | 3 | ||||
| -rw-r--r-- | src/libstd/option.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rc.rs | 25 |
3 files changed, 15 insertions, 17 deletions
diff --git a/src/libstd/hash/mod.rs b/src/libstd/hash/mod.rs index 3791aa38b82..dc7d5c5b9c7 100644 --- a/src/libstd/hash/mod.rs +++ b/src/libstd/hash/mod.rs @@ -66,7 +66,6 @@ use container::Container; use io::Writer; use iter::Iterator; -use ops::Deref; use option::{Option, Some, None}; use rc::Rc; use str::{Str, StrSlice}; @@ -247,7 +246,7 @@ impl<S: Writer, T: Hash<S>> Hash<S> for @T { impl<S: Writer, T: Hash<S>> Hash<S> for Rc<T> { #[inline] fn hash(&self, state: &mut S) { - self.deref().hash(state); + (**self).hash(state); } } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 5f733302d6f..23363a97845 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -650,7 +650,7 @@ mod tests { #[unsafe_destructor] impl ::ops::Drop for R { fn drop(&mut self) { - let ii = self.i.deref(); + let ii = &*self.i; ii.set(ii.get() + 1); } } @@ -667,7 +667,7 @@ mod tests { let opt = Some(x); let _y = opt.unwrap(); } - assert_eq!(i.deref().get(), 1); + assert_eq!(i.get(), 1); } #[test] diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 490b3068dda..8dd06cb9232 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -122,24 +122,23 @@ impl<T> Clone for Rc<T> { impl<T: Eq> Eq for Rc<T> { #[inline(always)] - fn eq(&self, other: &Rc<T>) -> bool { *self.deref() == *other.deref() } - + fn eq(&self, other: &Rc<T>) -> bool { **self == **other } #[inline(always)] - fn ne(&self, other: &Rc<T>) -> bool { *self.deref() != *other.deref() } + fn ne(&self, other: &Rc<T>) -> bool { **self != **other } } impl<T: Ord> Ord for Rc<T> { #[inline(always)] - fn lt(&self, other: &Rc<T>) -> bool { *self.deref() < *other.deref() } + fn lt(&self, other: &Rc<T>) -> bool { **self < **other } #[inline(always)] - fn le(&self, other: &Rc<T>) -> bool { *self.deref() <= *other.deref() } + fn le(&self, other: &Rc<T>) -> bool { **self <= **other } #[inline(always)] - fn gt(&self, other: &Rc<T>) -> bool { *self.deref() > *other.deref() } + fn gt(&self, other: &Rc<T>) -> bool { **self > **other } #[inline(always)] - fn ge(&self, other: &Rc<T>) -> bool { *self.deref() >= *other.deref() } + fn ge(&self, other: &Rc<T>) -> bool { **self >= **other } } /// Weak reference to a reference-counted box @@ -236,21 +235,21 @@ mod tests { #[test] fn test_simple() { let x = Rc::new(5); - assert_eq!(*x.deref(), 5); + assert_eq!(*x, 5); } #[test] fn test_simple_clone() { let x = Rc::new(5); let y = x.clone(); - assert_eq!(*x.deref(), 5); - assert_eq!(*y.deref(), 5); + assert_eq!(*x, 5); + assert_eq!(*y, 5); } #[test] fn test_destructor() { let x = Rc::new(~5); - assert_eq!(**x.deref(), 5); + assert_eq!(**x, 5); } #[test] @@ -273,7 +272,7 @@ mod tests { // see issue #11532 use gc::Gc; let a = Rc::new(RefCell::new(Gc::new(1))); - assert!(a.deref().try_borrow_mut().is_some()); + assert!(a.try_borrow_mut().is_some()); } #[test] @@ -284,7 +283,7 @@ mod tests { let a = Rc::new(Cycle { x: RefCell::new(None) }); let b = a.clone().downgrade(); - *a.deref().x.borrow_mut() = Some(b); + *a.x.borrow_mut() = Some(b); // hopefully we don't double-free (or leak)... } |
