aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/hosts.rs
diff options
context:
space:
mode:
authorClar Charr <clar@charr.xyz>2017-07-06 00:43:22 -0400
committerClar Charr <clar@charr.xyz>2017-07-06 21:37:31 -0400
commitd86fa9d25bc81d8d9c979b29afb624b590f80f3f (patch)
tree96101b872a9179c9e44a72b30324400673327b88 /components/net/hosts.rs
parentba2a6c17270f6d4b5bffef6c1a745f0817006289 (diff)
downloadservo-d86fa9d25bc81d8d9c979b29afb624b590f80f3f.tar.gz
servo-d86fa9d25bc81d8d9c979b29afb624b590f80f3f.zip
Update parse-hosts.
Diffstat (limited to 'components/net/hosts.rs')
-rw-r--r--components/net/hosts.rs17
1 files changed, 4 insertions, 13 deletions
diff --git a/components/net/hosts.rs b/components/net/hosts.rs
index adc46e870ea..768108052e7 100644
--- a/components/net/hosts.rs
+++ b/components/net/hosts.rs
@@ -41,19 +41,10 @@ pub fn replace_host_table(table: HashMap<String, IpAddr>) {
}
pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> {
- let mut host_table = HashMap::new();
-
- for line in HostsFile::read_buffered(hostsfile_content.as_bytes()).lines() {
- if let Ok(ref line) = line {
- for host in line.hosts() {
- if let Some(ip) = line.ip() {
- host_table.insert(host.to_owned(), ip);
- }
- }
- }
- }
-
- host_table
+ HostsFile::read_buffered(hostsfile_content.as_bytes())
+ .pairs()
+ .filter_map(Result::ok)
+ .collect()
}
pub fn replace_host(host: &str) -> Cow<str> {