mirror of
https://github.com/bertptrs/tracing-mutex.git
synced 2025-12-27 21:40: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 {
|
impl fmt::Debug for MutexId {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "MutexID({:?})", self.0)
|
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
|
/// Refer to the [crate-level][`crate`] documentaiton for the differences between this struct and
|
||||||
/// the one it wraps.
|
/// the one it wraps.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Default)]
|
||||||
pub struct TracingMutex<T> {
|
pub struct TracingMutex<T> {
|
||||||
inner: Mutex<T>,
|
inner: Mutex<T>,
|
||||||
id: MutexId,
|
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> {
|
impl<T> From<T> for TracingMutex<T> {
|
||||||
fn from(t: T) -> Self {
|
fn from(t: T) -> Self {
|
||||||
Self::new(t)
|
Self::new(t)
|
||||||
@@ -241,12 +235,9 @@ impl<T> TracingRwLock<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Default for TracingRwLock<T>
|
impl<T> From<T> for TracingRwLock<T> {
|
||||||
where
|
fn from(t: T) -> Self {
|
||||||
T: Default,
|
Self::new(t)
|
||||||
{
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new(T::default())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user