From 3fb1ed0e046e4208ea8a28f989d1b184143d62ce Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 20 Mar 2014 22:10:44 -0700 Subject: rustc: Remove all usage of manual deref() Favor using '*' instead --- src/libstd/hash/mod.rs | 3 +-- src/libstd/option.rs | 4 ++-- src/libstd/rc.rs | 25 ++++++++++++------------- 3 files changed, 15 insertions(+), 17 deletions(-) (limited to 'src/libstd') 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> Hash for @T { impl> Hash for Rc { #[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 Clone for Rc { impl Eq for Rc { #[inline(always)] - fn eq(&self, other: &Rc) -> bool { *self.deref() == *other.deref() } - + fn eq(&self, other: &Rc) -> bool { **self == **other } #[inline(always)] - fn ne(&self, other: &Rc) -> bool { *self.deref() != *other.deref() } + fn ne(&self, other: &Rc) -> bool { **self != **other } } impl Ord for Rc { #[inline(always)] - fn lt(&self, other: &Rc) -> bool { *self.deref() < *other.deref() } + fn lt(&self, other: &Rc) -> bool { **self < **other } #[inline(always)] - fn le(&self, other: &Rc) -> bool { *self.deref() <= *other.deref() } + fn le(&self, other: &Rc) -> bool { **self <= **other } #[inline(always)] - fn gt(&self, other: &Rc) -> bool { *self.deref() > *other.deref() } + fn gt(&self, other: &Rc) -> bool { **self > **other } #[inline(always)] - fn ge(&self, other: &Rc) -> bool { *self.deref() >= *other.deref() } + fn ge(&self, other: &Rc) -> 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)... } -- cgit 1.4.1-3-g733a5