title: How can an IpAddr be converted to an IPv4Addr?
body: <p>In Rust, it is easy to create an <code>IpAddr</code> from an <code>IpV4Addr</code>:</p>
  
  <pre><code>let ipv4 = IpV4Addr::new(127,0,0,1);
  let ip = IpAddr::V4(ipv4);
  </code></pre>
  
  <p>But it seems that there is no way back:</p>
  
  <pre><code>if ip.is_ipv4() {
      let ipv4: IpV4Addr = .....?
  }
  </code></pre>
  
  <p>The reason is that I need to access the octets of the IPv4 address at some point (via <code>IPv4::octets</code>) to transfer them over the network. However, I'd like to use the more generic <code>IpAddr</code> representation in other parts of the application, since I want to implement IPv6 in the future, therefore making the network code not IPv4-specific.</p>