From dd9ad18ec4be22b4ace7db4cf6bfaa2eb4acd028 Mon Sep 17 00:00:00 2001 From: Lee Smet Date: Tue, 19 Sep 2023 10:25:01 +0200 Subject: [PATCH] Add network method to Subnet Signed-off-by: Lee Smet --- src/subnet.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/subnet.rs b/src/subnet.rs index 7e06051..9be724e 100644 --- a/src/subnet.rs +++ b/src/subnet.rs @@ -61,10 +61,15 @@ impl Subnet { self.inner.contains(&other.inner) } - /// Cheks if this `Subnet` contains the provided [`IpAddr`]. + /// Checks if this `Subnet` contains the provided [`IpAddr`]. pub fn contains_ip(&self, ip: IpAddr) -> bool { self.inner.contains(&ip) } + + /// Returns the network part of the `Subnet`. All non prefix bits are set to 0. + pub fn network(&self) -> IpAddr { + self.inner.network() + } } impl fmt::Display for Subnet {