about summary refs log tree commit diff
path: root/src/liballoc/rc.rs
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2015-09-24 10:00:54 +1200
committerNick Cameron <ncameron@mozilla.com>2015-09-24 10:00:54 +1200
commit8f51c8d687cb6fd7e98f68b93f40445ecd4690fa (patch)
treefee062e380e807b431755b73ba78d8128683f906 /src/liballoc/rc.rs
parentafae2ff723393b3ab4ccffef6ac7c6d1809e2da0 (diff)
downloadrust-8f51c8d687cb6fd7e98f68b93f40445ecd4690fa.tar.gz
rust-8f51c8d687cb6fd7e98f68b93f40445ecd4690fa.zip
rustfmt liballoc
Diffstat (limited to 'src/liballoc/rc.rs')
-rw-r--r--src/liballoc/rc.rs71
1 files changed, 48 insertions, 23 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 4fe474cef0a..47db2e48f2d 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -213,7 +213,7 @@ impl<T> Rc<T> {
                 _ptr: NonZero::new(Box::into_raw(box RcBox {
                     strong: Cell::new(1),
                     weak: Cell::new(1),
-                    value: value
+                    value: value,
                 })),
             }
         }
@@ -290,13 +290,17 @@ impl<T: ?Sized> Rc<T> {
     #[inline]
     #[unstable(feature = "rc_counts", reason = "not clearly useful",
                issue = "28356")]
-    pub fn weak_count(this: &Self) -> usize { this.weak() - 1 }
+    pub fn weak_count(this: &Self) -> usize {
+        this.weak() - 1
+    }
 
     /// Get the number of strong references to this value.
     #[inline]
     #[unstable(feature = "rc_counts", reason = "not clearly useful",
                issue = "28356")]
-    pub fn strong_count(this: &Self) -> usize { this.strong() }
+    pub fn strong_count(this: &Self) -> usize {
+        this.strong()
+    }
 
     /// Returns true if there are no other `Rc` or `Weak<T>` values that share
     /// the same inner value.
@@ -451,7 +455,7 @@ impl<T: ?Sized> Drop for Rc<T> {
         unsafe {
             let ptr = *self._ptr;
             if !(*(&ptr as *const _ as *const *const ())).is_null() &&
-                ptr as *const () as usize != mem::POST_DROP_USIZE {
+               ptr as *const () as usize != mem::POST_DROP_USIZE {
                 self.dec_strong();
                 if self.strong() == 0 {
                     // destroy the contained object
@@ -462,9 +466,7 @@ impl<T: ?Sized> Drop for Rc<T> {
                     self.dec_weak();
 
                     if self.weak() == 0 {
-                        deallocate(ptr as *mut u8,
-                                   size_of_val(&*ptr),
-                                   align_of_val(&*ptr))
+                        deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
                     }
                 }
             }
@@ -530,7 +532,9 @@ impl<T: ?Sized + PartialEq> PartialEq for Rc<T> {
     /// five == Rc::new(5);
     /// ```
     #[inline(always)]
-    fn eq(&self, other: &Rc<T>) -> bool { **self == **other }
+    fn eq(&self, other: &Rc<T>) -> bool {
+        **self == **other
+    }
 
     /// Inequality for two `Rc<T>`s.
     ///
@@ -546,7 +550,9 @@ impl<T: ?Sized + PartialEq> PartialEq for Rc<T> {
     /// five != Rc::new(5);
     /// ```
     #[inline(always)]
-    fn ne(&self, other: &Rc<T>) -> bool { **self != **other }
+    fn ne(&self, other: &Rc<T>) -> bool {
+        **self != **other
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -586,7 +592,9 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Rc<T> {
     /// five < Rc::new(5);
     /// ```
     #[inline(always)]
-    fn lt(&self, other: &Rc<T>) -> bool { **self < **other }
+    fn lt(&self, other: &Rc<T>) -> bool {
+        **self < **other
+    }
 
     /// 'Less-than or equal to' comparison for two `Rc<T>`s.
     ///
@@ -602,7 +610,9 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Rc<T> {
     /// five <= Rc::new(5);
     /// ```
     #[inline(always)]
-    fn le(&self, other: &Rc<T>) -> bool { **self <= **other }
+    fn le(&self, other: &Rc<T>) -> bool {
+        **self <= **other
+    }
 
     /// Greater-than comparison for two `Rc<T>`s.
     ///
@@ -618,7 +628,9 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Rc<T> {
     /// five > Rc::new(5);
     /// ```
     #[inline(always)]
-    fn gt(&self, other: &Rc<T>) -> bool { **self > **other }
+    fn gt(&self, other: &Rc<T>) -> bool {
+        **self > **other
+    }
 
     /// 'Greater-than or equal to' comparison for two `Rc<T>`s.
     ///
@@ -634,7 +646,9 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Rc<T> {
     /// five >= Rc::new(5);
     /// ```
     #[inline(always)]
-    fn ge(&self, other: &Rc<T>) -> bool { **self >= **other }
+    fn ge(&self, other: &Rc<T>) -> bool {
+        **self >= **other
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -653,7 +667,9 @@ impl<T: ?Sized + Ord> Ord for Rc<T> {
     /// five.partial_cmp(&Rc::new(5));
     /// ```
     #[inline]
-    fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) }
+    fn cmp(&self, other: &Rc<T>) -> Ordering {
+        (**self).cmp(&**other)
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -764,13 +780,12 @@ impl<T: ?Sized> Drop for Weak<T> {
         unsafe {
             let ptr = *self._ptr;
             if !(*(&ptr as *const _ as *const *const ())).is_null() &&
-                ptr as *const () as usize != mem::POST_DROP_USIZE {
+               ptr as *const () as usize != mem::POST_DROP_USIZE {
                 self.dec_weak();
                 // the weak count starts at 1, and will only go to zero if all
                 // the strong pointers have disappeared.
                 if self.weak() == 0 {
-                    deallocate(ptr as *mut u8, size_of_val(&*ptr),
-                               align_of_val(&*ptr))
+                    deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr))
                 }
             }
         }
@@ -821,7 +836,9 @@ trait RcBoxPtr<T: ?Sized> {
     fn inner(&self) -> &RcBox<T>;
 
     #[inline]
-    fn strong(&self) -> usize { self.inner().strong.get() }
+    fn strong(&self) -> usize {
+        self.inner().strong.get()
+    }
 
     #[inline]
     fn inc_strong(&self) {
@@ -829,10 +846,14 @@ trait RcBoxPtr<T: ?Sized> {
     }
 
     #[inline]
-    fn dec_strong(&self) { self.inner().strong.set(self.strong() - 1); }
+    fn dec_strong(&self) {
+        self.inner().strong.set(self.strong() - 1);
+    }
 
     #[inline]
-    fn weak(&self) -> usize { self.inner().weak.get() }
+    fn weak(&self) -> usize {
+        self.inner().weak.get()
+    }
 
     #[inline]
     fn inc_weak(&self) {
@@ -840,7 +861,9 @@ trait RcBoxPtr<T: ?Sized> {
     }
 
     #[inline]
-    fn dec_weak(&self) { self.inner().weak.set(self.weak() - 1); }
+    fn dec_weak(&self) {
+        self.inner().weak.set(self.weak() - 1);
+    }
 }
 
 impl<T: ?Sized> RcBoxPtr<T> for Rc<T> {
@@ -928,7 +951,7 @@ mod tests {
     #[test]
     fn weak_self_cyclic() {
         struct Cycle {
-            x: RefCell<Option<Weak<Cycle>>>
+            x: RefCell<Option<Weak<Cycle>>>,
         }
 
         let a = Rc::new(Cycle { x: RefCell::new(None) });
@@ -1086,5 +1109,7 @@ mod tests {
 }
 
 impl<T: ?Sized> borrow::Borrow<T> for Rc<T> {
-    fn borrow(&self) -> &T { &**self }
+    fn borrow(&self) -> &T {
+        &**self
+    }
 }