Skip to content

Commit

Permalink
discover: Implement Clone for Change
Browse files Browse the repository at this point in the history
Implements Clone for discover::Change, if the underlying key and value
both implement clone.

This is convenient for use-cases where a single change needs to be
duplicated, and sent to multiple discover streams.
  • Loading branch information
samvrlewis committed Oct 13, 2022
1 parent 87fa8ef commit 34a9e71
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tower/src/discover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,16 @@ pub enum Change<K, V> {
/// The service identified by key `K` disappeared.
Remove(K),
}

impl<K, V> Clone for Change<K, V>
where
K: Clone,
V: Clone,
{
fn clone(&self) -> Self {
match self {
Change::Insert(k, v) => Change::Insert(k.clone(), v.clone()),
Change::Remove(k) => Change::Remove(k.clone()),
}
}
}

0 comments on commit 34a9e71

Please sign in to comment.