Another important type in the standard library is IpAddr, which represents an IP address. Not surprisingly, it is an enum with two variants, one for v4 addresses and the other for v6 addresses. All of these types have methods to classify addresses according to their types (global, loopback, multicast, and so on). Note that a number of these methods are not stabilized yet and hence are only available in the nightly compiler. They are behind a feature flag named ip which must be included in the crate root so that you can use those methods. A closely related type is SocketAddr, which is a combination of an IP address and a port number. Thus, this also has two variants, one for v4 and one for v6. Let's look at some examples:
// chapter3/ip-socket-addr.rs
#![feature(ip)]
use std::net::{IpAddr, SocketAddr};
fn main() {
// construct an IpAddr...