Repository: achanda/ipnetwork (language: rust)

Issue:
Iterators are not public
The types `Ipv4NetworkIterator` and `Ipv6NetworkIterator` are not public types in the library. But you can get them from the `iter` methods on the network types. They should probably be exported?

Also, these hidden iterator types implement `Copy`. Iterators should usually *not* implement `Copy`. Because using them becomes very confusing. Every time you pass the iterator somewhere by value it's copied and the original instance stays where it was and can still be iterated. Meaning you can use a single iterator to iterate over the "collection" many times.


Discussion / hints:

Fix patch:
diff --git a/src/ipv4.rs b/src/ipv4.rs
index a944598..82472b7 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -271,7 +271,7 @@ impl From<Ipv4Addr> for Ipv4Network {
     }
 }
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Clone, Debug)]
 pub struct Ipv4NetworkIterator {
     next: Option<u32>,
     end: u32,
diff --git a/src/ipv6.rs b/src/ipv6.rs
index 558bc6e..872522e 100644
--- a/src/ipv6.rs
+++ b/src/ipv6.rs
@@ -249,7 +249,7 @@ impl From<Ipv6Addr> for Ipv6Network {
     }
 }
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Clone, Debug)]
 pub struct Ipv6NetworkIterator {
     next: Option<u128>,
     end: u128,
diff --git a/src/lib.rs b/src/lib.rs
index 5a02b4a..2adb722 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,7 +3,7 @@
 #![crate_type = "lib"]
 #![doc(html_root_url = "https://docs.rs/ipnetwork/0.17.0")]
 
-#![deny(missing_copy_implementations,
+#![deny(
     missing_debug_implementations,
     unsafe_code,
     unused_extern_crates,
@@ -16,9 +16,9 @@ mod ipv4;
 mod ipv6;
 
 pub use crate::common::IpNetworkError;
-use crate::ipv4::Ipv4NetworkIterator;
+pub use crate::ipv4::Ipv4NetworkIterator;
 pub use crate::ipv4::{ipv4_mask_to_prefix, Ipv4Network};
-use crate::ipv6::Ipv6NetworkIterator;
+pub use crate::ipv6::Ipv6NetworkIterator;
 pub use crate::ipv6::{ipv6_mask_to_prefix, Ipv6Network};
 
 /// Represents a generic network range. This type can have two variants:


Test patch: