From a288c40034c6284fc8e6ff92564cfc2fe2dd8989 Mon Sep 17 00:00:00 2001 From: Bernardo Uriarte Date: Sun, 4 Sep 2022 18:40:54 +0200 Subject: [PATCH] simplify paths --- components/salsa-2022/src/debug.rs | 84 ++++++------------------------ 1 file changed, 15 insertions(+), 69 deletions(-) diff --git a/components/salsa-2022/src/debug.rs b/components/salsa-2022/src/debug.rs index 02476a37..6571cc19 100644 --- a/components/salsa-2022/src/debug.rs +++ b/components/salsa-2022/src/debug.rs @@ -1,5 +1,6 @@ use std::{ collections::{HashMap, HashSet}, + fmt, rc::Rc, sync::Arc, }; @@ -66,12 +67,7 @@ pub trait DebugWithDb { } } - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result; + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result; } pub struct DebugWith<'me, Db: ?Sized> { @@ -96,8 +92,8 @@ impl std::ops::Deref for BoxRef<'_, T> { } } -impl std::fmt::Debug for DebugWith<'_, D> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl fmt::Debug for DebugWith<'_, D> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { DebugWithDb::fmt(&*self.value, f, self.db, self.include_all_fields) } } @@ -106,12 +102,7 @@ impl DebugWithDb for &T where T: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { T::fmt(self, f, db, include_all_fields) } } @@ -120,12 +111,7 @@ impl DebugWithDb for Box where T: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { T::fmt(self, f, db, include_all_fields) } } @@ -134,12 +120,7 @@ impl DebugWithDb for Rc where T: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { T::fmt(self, f, db, include_all_fields) } } @@ -148,12 +129,7 @@ impl DebugWithDb for Arc where T: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { T::fmt(self, f, db, include_all_fields) } } @@ -162,12 +138,7 @@ impl DebugWithDb for Vec where T: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { let elements = self.iter().map(|e| e.debug_with(db, include_all_fields)); f.debug_list().entries(elements).finish() } @@ -177,14 +148,9 @@ impl DebugWithDb for Option where T: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { let me = self.as_ref().map(|v| v.debug_with(db, include_all_fields)); - std::fmt::Debug::fmt(&me, f) + fmt::Debug::fmt(&me, f) } } @@ -193,12 +159,7 @@ where K: DebugWithDb, V: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { let elements = self.iter().map(|(k, v)| { ( k.debug_with(db, include_all_fields), @@ -214,12 +175,7 @@ where A: DebugWithDb, B: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { f.debug_tuple("") .field(&self.0.debug_with(db, include_all_fields)) .field(&self.1.debug_with(db, include_all_fields)) @@ -233,12 +189,7 @@ where B: DebugWithDb, C: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { f.debug_tuple("") .field(&self.0.debug_with(db, include_all_fields)) .field(&self.1.debug_with(db, include_all_fields)) @@ -251,12 +202,7 @@ impl DebugWithDb for HashSet where V: DebugWithDb, { - fn fmt( - &self, - f: &mut std::fmt::Formatter<'_>, - db: &Db, - include_all_fields: bool, - ) -> std::fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>, db: &Db, include_all_fields: bool) -> fmt::Result { let elements = self.iter().map(|e| e.debug_with(db, include_all_fields)); f.debug_list().entries(elements).finish() }