Derive Default more rather than implement it

This commit is contained in:
2021-05-08 14:28:51 +02:00
parent 050ee27af6
commit eb7abc70ea
2 changed files with 10 additions and 13 deletions

View File

@@ -137,6 +137,12 @@ impl MutexId {
}
}
impl Default for MutexId {
fn default() -> Self {
Self::new()
}
}
impl fmt::Debug for MutexId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "MutexID({:?})", self.0)

View File

@@ -53,7 +53,7 @@ pub type DebugRwLock<T> = RwLock<T>;
///
/// Refer to the [crate-level][`crate`] documentaiton for the differences between this struct and
/// the one it wraps.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct TracingMutex<T> {
inner: Mutex<T>,
id: MutexId,
@@ -139,12 +139,6 @@ impl<T> TracingMutex<T> {
}
}
impl<T: ?Sized + Default> Default for TracingMutex<T> {
fn default() -> Self {
Self::new(T::default())
}
}
impl<T> From<T> for TracingMutex<T> {
fn from(t: T) -> Self {
Self::new(t)
@@ -241,12 +235,9 @@ impl<T> TracingRwLock<T> {
}
}
impl<T> Default for TracingRwLock<T>
where
T: Default,
{
fn default() -> Self {
Self::new(T::default())
impl<T> From<T> for TracingRwLock<T> {
fn from(t: T) -> Self {
Self::new(t)
}
}