mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Replace the lazy_static crate with std::sync::LazyLock
in components/shared (#33060)
* replace in pub_domains.rs Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in embedder/resources.rs Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in base/id.rs Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * replace in net/lib.rs Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> * remove lazy_static from components/shared Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com> --------- Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
parent
8f82b2a7cb
commit
86c4e014b4
10 changed files with 19 additions and 37 deletions
|
@ -3,13 +3,12 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::RwLock;
|
||||
use std::sync::{LazyLock, RwLock};
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
static ref RES: RwLock<Option<Box<dyn ResourceReaderMethods + Sync + Send>>> = {
|
||||
static RES: LazyLock<RwLock<Option<Box<dyn ResourceReaderMethods + Sync + Send>>>> =
|
||||
LazyLock::new(|| {
|
||||
cfg_if! {
|
||||
if #[cfg(servo_production)] {
|
||||
RwLock::new(None)
|
||||
|
@ -21,8 +20,7 @@ lazy_static! {
|
|||
RwLock::new(Some(resources_for_tests()))
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
pub fn set(reader: Box<dyn ResourceReaderMethods + Sync + Send>) {
|
||||
*RES.write().unwrap() = Some(reader);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue