feat: derive Clone for mdns::Event

Derive trait `Clone` for `mdns::Event`. This makes cloning its contents without destroying type information possible.



Related #3593.

Pull-Request: #3606.
This commit is contained in:
DrHuangMHT 2023-03-14 01:17:03 +08:00 committed by GitHub
parent 8927abf176
commit 9d05c619e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,8 @@
# 0.43.1 [unreleased]
- Derive `Clone` for `mdns::Event`. See [PR 3606].
[PR 3606]: https://github.com/libp2p/rust-libp2p/pull/3606
# 0.43.0 # 0.43.0
- Update to `libp2p-core` `v0.39.0`. - Update to `libp2p-core` `v0.39.0`.

View File

@ -339,7 +339,7 @@ where
} }
/// Event that can be produced by the `Mdns` behaviour. /// Event that can be produced by the `Mdns` behaviour.
#[derive(Debug)] #[derive(Debug, Clone)]
pub enum Event { pub enum Event {
/// Discovered nodes through mDNS. /// Discovered nodes through mDNS.
Discovered(DiscoveredAddrsIter), Discovered(DiscoveredAddrsIter),
@ -352,6 +352,7 @@ pub enum Event {
} }
/// Iterator that produces the list of addresses that have been discovered. /// Iterator that produces the list of addresses that have been discovered.
#[derive(Clone)]
pub struct DiscoveredAddrsIter { pub struct DiscoveredAddrsIter {
inner: smallvec::IntoIter<[(PeerId, Multiaddr); 4]>, inner: smallvec::IntoIter<[(PeerId, Multiaddr); 4]>,
} }
@ -379,6 +380,7 @@ impl fmt::Debug for DiscoveredAddrsIter {
} }
/// Iterator that produces the list of addresses that have expired. /// Iterator that produces the list of addresses that have expired.
#[derive(Clone)]
pub struct ExpiredAddrsIter { pub struct ExpiredAddrsIter {
inner: smallvec::IntoIter<[(PeerId, Multiaddr); 4]>, inner: smallvec::IntoIter<[(PeerId, Multiaddr); 4]>,
} }