This PR implements the Sub trait for IpNetwork, Ipv4Network and Ipv6Network. There are two possibilities: either a single IP network item is subtracted from the original IP network, or multiple IP network items are subtracted from the original IP network.
The result of the subtraction operation is always an iterator, which can contain zero or more IP network items. For subtracting a single item, the iterator has a rather simple representation in memory and does implement Copy. When subtracting multiple items, a linked list of Box<dyn Iterator> is returned, so the resulting type has a more complex representation.
With this PR it is still not currently possible to subtract between IP networks with different protocols (for example, subtract an IPv4 network from an IPv6 network or vice-versa). Attempting to do so will lead the code to panic.
This PR implements the
Sub
trait forIpNetwork
,Ipv4Network
andIpv6Network
. There are two possibilities: either a single IP network item is subtracted from the original IP network, or multiple IP network items are subtracted from the original IP network.The result of the subtraction operation is always an iterator, which can contain zero or more IP network items. For subtracting a single item, the iterator has a rather simple representation in memory and does implement
Copy
. When subtracting multiple items, a linked list ofBox<dyn Iterator>
is returned, so the resulting type has a more complex representation.With this PR it is still not currently possible to subtract between IP networks with different protocols (for example, subtract an IPv4 network from an IPv6 network or vice-versa). Attempting to do so will lead the code to panic.