From acfd1cbe8544aaad00dd9478e82a2a057600c1b3 Mon Sep 17 00:00:00 2001 From: Anders Musikka Date: Mon, 19 Aug 2024 17:15:41 +0200 Subject: [PATCH] cargo fmt --- arcshift/src/lib.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/arcshift/src/lib.rs b/arcshift/src/lib.rs index 0bba62a..2a65035 100644 --- a/arcshift/src/lib.rs +++ b/arcshift/src/lib.rs @@ -315,18 +315,26 @@ pub struct ArcShift { item: NonNull>, } - -impl Debug for ArcShift where T:Debug{ +impl Debug for ArcShift +where + T: Debug, +{ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "ArcShift({:?})", self.shared_get()) } } -impl Debug for ArcShiftLight where T:Debug{ +impl Debug for ArcShiftLight +where + T: Debug, +{ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "ArcShiftLight(..)") } } -impl Debug for ArcShiftCell where T:Debug{ +impl Debug for ArcShiftCell +where + T: Debug, +{ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "ArcShiftCell({:?})", &*self.borrow()) } @@ -378,7 +386,7 @@ unsafe impl Sync for ArcShiftLight where T: Sync {} /// but if it is leaked, the effect is that whatever value the ArcShiftCell-instance /// pointed to at that time, will forever leak also. All the linked-list nodes from /// that entry and onward will also leak. So make sure to not leak the handle! -pub struct ArcShiftCell { +pub struct ArcShiftCell { inner: UnsafeCell>, recursion: Cell, } @@ -477,8 +485,7 @@ impl ArcShiftCell { ArcShiftCell::from_arcshift(ArcShift::new(value)) } } -impl ArcShiftCell { - +impl ArcShiftCell { /// Creates an ArcShiftCell from an ArcShift-instance. /// The payload is not cloned, the two pointers keep pointing to the same object. pub fn from_arcshift(input: ArcShift) -> ArcShiftCell { @@ -1060,7 +1067,6 @@ impl ArcShiftLight { ); } } - } impl ArcShiftLight { @@ -1153,7 +1159,6 @@ impl ArcShiftLight { } } - /// Update the contents of this ArcShift, and all other instances cloned from this /// instance. The next time such an instance of ArcShift is dereferenced, this /// new value will be returned. @@ -1282,8 +1287,6 @@ impl ArcShiftLight { let new_ptr = ArcShift::from_box_impl(new_payload); ArcShift::update_shared_impl(self.item.as_ptr(), new_ptr as *mut _, true, null()); } - - } impl Drop for ArcShiftLight { @@ -1305,7 +1308,8 @@ impl Drop for ArcShift { fn drop(&mut self) { verify_item(get_ptr(self.item)); - if !undecorate(get_next_and_state(self.item.as_ptr()).load(Ordering::Relaxed)).is_null() { //Fast-path, when 'next' is null, don't do the expensive and complicated 'reload' + if !undecorate(get_next_and_state(self.item.as_ptr()).load(Ordering::Relaxed)).is_null() { + //Fast-path, when 'next' is null, don't do the expensive and complicated 'reload' self.reload(); } debug_println!("ArcShift::drop({:?}) - reloaded", self.item); @@ -1581,7 +1585,7 @@ impl Clone for ArcShift { ArcShift { item: self.item } } } -impl Deref for ArcShift { +impl Deref for ArcShift { type Target = T; fn deref(&self) -> &Self::Target {