Trait ipnet::IpBitOr [] [src]

pub trait IpBitOr<RHS = Self> {
    type Output;
    fn bitor(self, rhs: RHS) -> Self::Output;
}

Provides a bitor() method for Ipv4Addr and Ipv6Addr.

Examples

use std::net::{Ipv4Addr, Ipv6Addr};
use std::str::FromStr;
use ipnet::IpBitOr;

let ip0 = Ipv4Addr::from_str("0.0.0.0").unwrap();
let ip1 = Ipv4Addr::from_str("1.1.1.1").unwrap();
let ip2 = Ipv4Addr::from_str("2.2.2.2").unwrap();

assert_eq!(ip0.bitor(ip1), Ipv4Addr::from_str("1.1.1.1").unwrap());
assert_eq!(ip1.bitor(ip1), Ipv4Addr::from_str("1.1.1.1").unwrap());
assert_eq!(ip1.bitor(ip2), Ipv4Addr::from_str("3.3.3.3").unwrap());
 
let ip60 = Ipv6Addr::from_str("::").unwrap();
let ip61 = Ipv6Addr::from_str("::1").unwrap();
let ip62 = Ipv6Addr::from_str("::2").unwrap();

assert_eq!(ip60.bitor(ip61), Ipv6Addr::from_str("::1").unwrap());
assert_eq!(ip61.bitor(ip61), Ipv6Addr::from_str("::1").unwrap());
assert_eq!(ip61.bitor(ip62), Ipv6Addr::from_str("::3").unwrap());

Associated Types

Required Methods

Implementors