#![feature(net)]

extern crate anymap;

use std::net::IpAddr;
use anymap::AnyMap;

#[derive(Debug)]
enum HostAddress {
    DomainName(String),
    Ip(IpAddr),
}

#[derive(Debug)]
struct Port(u32);

#[derive(Debug)]
struct ConnectionLimit(u32);

fn main() {
    println!("24 days of Rust - anymap (day 9)");
    let mut config = AnyMap::new();
    config.insert(HostAddress::DomainName("siciarz.net".to_string()));
    config.insert(Port(666));
    config.insert(ConnectionLimit(32));
    println!("{:?}", config.get::<HostAddress>());
    println!("{:?}", config.get::<Port>());
    assert!(config.get::<String>().is_none());
    assert!(config.get::<u32>().is_none());
    config.insert(HostAddress::Ip(IpAddr::new_v4(127, 0, 0, 1)));
    println!("{:?}", config.get::<HostAddress>());
    if config.contains::<Option<f32>>() {
        println!("There's no optional float in the configuration...");
    }
    let dummy: Option<f32> = None;
    config.insert(dummy);
    if config.contains::<Option<f32>>() {
        println!("There's an optional 32-bit float in the configuration...");
    }
    if !config.contains::<Option<f64>>() {
        println!("...but not an optional 64-bit float.");
    }
}

#![feature(io)]

extern crate anymap;

use std::old_io::net::ip::IpAddr;
use anymap::AnyMap;

#[derive(Debug)]
enum HostAddress {
    DomainName(String),
    Ip(IpAddr),
}

#[derive(Debug)]
struct Port(u32);

#[derive(Debug)]
struct ConnectionLimit(u32);

fn main() {
    println!("24 days of Rust - anymap (day 9)");
    let mut config = AnyMap::new();
    config.insert(HostAddress::DomainName("siciarz.net".to_string()));
    config.insert(Port(666));
    config.insert(ConnectionLimit(32));
    println!("{:?}", config.get::<HostAddress>());
    println!("{:?}", config.get::<Port>());
    assert!(config.get::<String>().is_none());
    assert!(config.get::<u32>().is_none());
    config.insert(HostAddress::Ip(IpAddr::Ipv4Addr(127, 0, 0, 1)));
    println!("{:?}", config.get::<HostAddress>());
    if config.contains::<Option<f32>>() {
        println!("There's no optional float in the configuration...");
    }
    let dummy: Option<f32> = None;
    config.insert(dummy);
    if config.contains::<Option<f32>>() {
        println!("There's an optional 32-bit float in the configuration...");
    }
    if !config.contains::<Option<f64>>() {
        println!("...but not an optional 64-bit float.");
    }
}

--- 
+++ 
@@ -1,8 +1,8 @@
-#![feature(io)]
+#![feature(net)]
 
 extern crate anymap;
 
-use std::old_io::net::ip::IpAddr;
+use std::net::IpAddr;
 use anymap::AnyMap;
 
 #[derive(Debug)]
@@ -27,7 +27,7 @@
     println!("{:?}", config.get::<Port>());
     assert!(config.get::<String>().is_none());
     assert!(config.get::<u32>().is_none());
-    config.insert(HostAddress::Ip(IpAddr::Ipv4Addr(127, 0, 0, 1)));
+    config.insert(HostAddress::Ip(IpAddr::new_v4(127, 0, 0, 1)));
     println!("{:?}", config.get::<HostAddress>());
     if config.contains::<Option<f32>>() {
         println!("There's no optional float in the configuration...");
Use new std::net module in day 9.
