# Trait ipnet::IpAdd [−] [src]

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

Provides a `saturating_add()` method for `Ipv4Addr` and `Ipv6Addr`.

Adding an integer to an IP address returns the modified IP address. A `u32` may added to an IPv4 address and a `u128` may be added to an IPv6 address.

# Examples

    use std::net::{Ipv4Addr, Ipv6Addr};
    use ipnet::IpAdd;

    let ip0: Ipv4Addr = "192.168.0.0".parse().unwrap();
    let ip1: Ipv4Addr = "192.168.0.5".parse().unwrap();
    let ip2: Ipv4Addr = "255.255.255.254".parse().unwrap();
    let max: Ipv4Addr = "255.255.255.255".parse().unwrap();

    assert_eq!(ip0.saturating_add(5), ip1);
    assert_eq!(ip2.saturating_add(1), max);
    assert_eq!(ip2.saturating_add(5), max);

    let ip0: Ipv6Addr = "fd00::".parse().unwrap();
    let ip1: Ipv6Addr = "fd00::5".parse().unwrap();
    let ip2: Ipv6Addr = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe".parse().unwrap();
    let max: Ipv6Addr = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff".parse().unwrap();

    assert_eq!(ip0.saturating_add(5), ip1);
    assert_eq!(ip2.saturating_add(1), max);
    assert_eq!(ip2.saturating_add(5), max);

## Associated Types

### `type Output` [src]

Loading content...

## Required methods

### `fn saturating_add(self, rhs: RHS) -> Self::Output` [src]

Loading content...

## Implementations on Foreign Types

### `impl IpAdd<u32> for Ipv4Addr` [src]

#### `type Output = Ipv4Addr`

#### `fn saturating_add(self, rhs: u32) -> Ipv4Addr` [src]

### `impl IpAdd<u128> for Ipv6Addr` [src]

#### `type Output = Ipv6Addr`

#### `fn saturating_add(self, rhs: u128) -> Ipv6Addr` [src]

Loading content...

## Implementors

Loading content...