Skip to content

Commit eec51cd

Browse files
author
bors-servo
authored
Auto merge of #17619 - clarcharr:master, r=SimonSapin
Update parse-hosts. The `parse-hosts` crate was recently updated so that it doesn't use any unstable features. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [X] These changes do not require tests because tests were already implemented. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17619) <!-- Reviewable:end -->
2 parents 9268540 + f2942d2 commit eec51cd

File tree

3 files changed

+58
-26
lines changed

3 files changed

+58
-26
lines changed

Cargo.lock

Lines changed: 53 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/net/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mime_guess = "1.8.0"
2828
msg = {path = "../msg"}
2929
net_traits = {path = "../net_traits"}
3030
openssl = "0.9"
31-
parse-hosts = "0.3.0"
31+
parse-hosts = "0.4.0"
3232
profile_traits = {path = "../profile_traits"}
3333
serde = "1.0"
3434
serde_json = "1.0"

components/net/hosts.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,10 @@ pub fn replace_host_table(table: HashMap<String, IpAddr>) {
4141
}
4242

4343
pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> {
44-
let mut host_table = HashMap::new();
45-
46-
for line in HostsFile::read_buffered(hostsfile_content.as_bytes()).lines() {
47-
if let Ok(ref line) = line {
48-
for host in line.hosts() {
49-
if let Some(ip) = line.ip() {
50-
host_table.insert(host.to_owned(), ip);
51-
}
52-
}
53-
}
54-
}
55-
56-
host_table
44+
HostsFile::read_buffered(hostsfile_content.as_bytes())
45+
.pairs()
46+
.filter_map(Result::ok)
47+
.collect()
5748
}
5849

5950
pub fn replace_host(host: &str) -> Cow<str> {

0 commit comments

Comments
 (0)