Skip to content

Commit

Permalink
feat(cordyceps): add Default impls (#502)
Browse files Browse the repository at this point in the history
Thanks clippy for reminding me to have these.
  • Loading branch information
hawkw committed Jan 4, 2025
1 parent 21a17b0 commit 213291d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cordyceps/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,12 @@ impl<T: Linked<Links<T>> + ?Sized> Drop for List<T> {
}
}

impl<T: Linked<Links<T>> + ?Sized> Default for List<T> {
fn default() -> Self {
Self::new()
}
}

// ==== impl Links ====

impl<T: ?Sized> Links<T> {
Expand Down
24 changes: 24 additions & 0 deletions cordyceps/src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ where
}
}

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

// === impl Stack ===

impl<T> Stack<T>
Expand Down Expand Up @@ -310,6 +319,15 @@ where
}
}

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

/// # Safety
///
/// A `Stack` is `Send` if `T` is send, because moving it across threads
Expand Down Expand Up @@ -376,6 +394,12 @@ impl<T> fmt::Debug for Links<T> {
}
}

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

#[cfg(test)]
mod loom {
use super::*;
Expand Down

0 comments on commit 213291d

Please sign in to comment.