Skip to content

Commit

Permalink
m: Implement Clone and Default for WeakLoopHandle manually
Browse files Browse the repository at this point in the history
The derived `Clone`/`Default` implementation adds `Clone`/`Default` bound on the generic parameter `Data`.
  • Loading branch information
Paraworker authored Jan 13, 2025
1 parent ba9ed53 commit 8225b69
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/loop_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ pub struct LoopHandle<'l, Data> {
}

/// Weak variant of a [`LoopHandle`]
#[derive(Clone, Default)]
pub struct WeakLoopHandle<'l, Data> {
inner: Weak<LoopInner<'l, Data>>,
}
Expand All @@ -79,6 +78,9 @@ impl<Data> Debug for LoopHandle<'_, Data> {
}
}

/// Manually implemented `Clone`.
///
/// The derived implementation adds a `Clone` bound on the generic parameter `Data`.
impl<Data> Clone for LoopHandle<'_, Data> {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn clone(&self) -> Self {
Expand Down Expand Up @@ -332,6 +334,30 @@ impl<Data> Debug for WeakLoopHandle<'_, Data> {
}
}

/// Manually implemented `Clone`.
///
/// The derived implementation adds a `Clone` bound on the generic parameter `Data`.
impl<Data> Clone for WeakLoopHandle<'_, Data> {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn clone(&self) -> Self {
WeakLoopHandle {
inner: self.inner.clone(),
}
}
}

/// Manually implemented `Default`.
///
/// The derived implementation adds a `Default` bound on the generic parameter `Data`.
impl<Data> Default for WeakLoopHandle<'_, Data> {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn default() -> Self {
WeakLoopHandle {
inner: Weak::default(),
}
}
}

impl<'l, Data> WeakLoopHandle<'l, Data> {
/// Try to get a [`LoopHandle`] from this weak reference.
///
Expand Down

0 comments on commit 8225b69

Please sign in to comment.