aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/hosts.rs
diff options
context:
space:
mode:
authorHayashi Mikihiro <34ttrweoewiwe28@gmail.com>2024-08-14 21:15:55 +0900
committerGitHub <noreply@github.com>2024-08-14 12:15:55 +0000
commit65f90ff1fd82758aa7644ada7bb75d34291c363f (patch)
treedbd1657dab933496904a676fdb5c830369b60f1b /components/net/hosts.rs
parent6be99241c64bb5c8c4df6be3c37a5f53829cd499 (diff)
downloadservo-65f90ff1fd82758aa7644ada7bb75d34291c363f.tar.gz
servo-65f90ff1fd82758aa7644ada7bb75d34291c363f.zip
Replace the lazy_static crate with std::sync::LazyLock in components/net (#33046)
* replace in net/fetch/methods.rs Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in net/hosts.rs Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in net/async_runtime.rs Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in net/tests/main.rs Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * remove lazy_static crate from components/net Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> --------- Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
Diffstat (limited to 'components/net/hosts.rs')
-rw-r--r--components/net/hosts.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/components/net/hosts.rs b/components/net/hosts.rs
index 6a59e04c76a..48b74bba154 100644
--- a/components/net/hosts.rs
+++ b/components/net/hosts.rs
@@ -8,13 +8,10 @@ use std::env;
use std::fs::File;
use std::io::{BufReader, Read};
use std::net::{IpAddr, Ipv4Addr};
-use std::sync::Mutex;
+use std::sync::{LazyLock, Mutex};
-use lazy_static::lazy_static;
-
-lazy_static! {
- static ref HOST_TABLE: Mutex<Option<HashMap<String, IpAddr>>> = Mutex::new(create_host_table());
-}
+static HOST_TABLE: LazyLock<Mutex<Option<HashMap<String, IpAddr>>>> =
+ LazyLock::new(|| Mutex::new(create_host_table()));
fn create_host_table() -> Option<HashMap<String, IpAddr>> {
let path = env::var_os("HOST_FILE")?;