Skip to content

Commit

Permalink
[ISSUE #1022]⚡️Add Default trait for RocketMQTokioRwLock and RocketMQ…
Browse files Browse the repository at this point in the history
…TokioMutex (#1023)
  • Loading branch information
mxsm authored Sep 30, 2024
1 parent 9a55483 commit 3dfebe6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions rocketmq/src/rocketmq_tokio_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ pub struct RocketMQTokioRwLock<T: ?Sized> {
lock: tokio::sync::RwLock<T>,
}

impl<T> Default for RocketMQTokioRwLock<T>
where
T: Default,
{
fn default() -> Self {
Self::new(T::default())
}
}

impl<T: ?Sized> RocketMQTokioRwLock<T> {
/// Creates a new `RocketMQTokioRwLock` instance containing the given data.
///
Expand Down Expand Up @@ -206,6 +215,15 @@ impl<T: ?Sized> RocketMQTokioMutex<T> {
}
}

impl<T> Default for RocketMQTokioMutex<T>
where
T: Default,
{
fn default() -> Self {
Self::new(T::default())
}
}

#[cfg(test)]
mod tests {
use std::sync::Arc;
Expand Down

0 comments on commit 3dfebe6

Please sign in to comment.