about summary refs log tree commit diff
path: root/src/libextra/net_ip.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-06-09 23:10:50 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2013-06-10 23:02:54 +1000
commit1e8982bdb26208d9d9ed4cdcbcd21cc9ef35bd46 (patch)
tree54f03a318e14bcdbdb56e01b3c80d00a9db87a17 /src/libextra/net_ip.rs
parent2ff6b298c5f23f48aa993fced41b6e29e446b7ce (diff)
std: replace str::each_split* with an iterator
Diffstat (limited to 'src/libextra/net_ip.rs')
-rw-r--r--src/libextra/net_ip.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/libextra/net_ip.rs b/src/libextra/net_ip.rs
index ddbf09e40eb..760fc7485e0 100644
--- a/src/libextra/net_ip.rs
+++ b/src/libextra/net_ip.rs
@@ -14,6 +14,7 @@
 
 use core::prelude::*;
 
+use core::iterator::IteratorUtil;
 use core::libc;
 use core::comm::{stream, SharedChan};
 use core::ptr;
@@ -158,9 +159,7 @@ pub mod v4 {
 
     use core::cast::transmute;
     use core::result;
-    use core::str;
     use core::uint;
-    use core::vec;
 
     /**
      * Convert a str to `ip_addr`
@@ -199,14 +198,12 @@ pub mod v4 {
         }
     }
     pub fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
-        let mut parts = ~[];
-        for str::each_split_char(ip, '.') |s| { parts.push(s.to_owned()) }
-        let parts = vec::map(parts, |s| {
-            match uint::from_str(*s) {
-              Some(n) if n <= 255 => n,
-              _ => 256
+        let parts: ~[uint] = ip.split_iter('.').transform(|s| {
+            match uint::from_str(s) {
+                Some(n) if n <= 255 => n,
+                _ => 256
             }
-        });
+        }).collect();
         if parts.len() != 4 {
             Err(fmt!("'%s' doesn't have 4 parts", ip))
         } else if parts.contains(&256) {