mirror of
https://github.com/bertptrs/tracing-mutex.git
synced 2025-12-25 20:50:32 +01:00
Derive Default more rather than implement it
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user