Skip to content

Commit 4c24b9f

Browse files
authored
Remove dependency on lazy static (#431)
The gstreamer/webrtc crates were depending on lazy_static, but not using it. In the case of the streams crate, lazy_static can be replaced by the LazyLock struct from the standard library. (https://doc.rust-lang.org/std/sync/struct.LazyLock.html) Signed-off-by: Simon Wülker <[email protected]>
1 parent 1ff6758 commit 4c24b9f

File tree

6 files changed

+7
-15
lines changed

6 files changed

+7
-15
lines changed

Cargo.lock

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backends/gstreamer/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ gst-webrtc = { workspace = true }
2323
gst-sdp = { workspace = true }
2424
gstreamer-sys = { workspace = true }
2525
ipc-channel = { workspace = true }
26-
lazy_static = "1.2.0"
2726
log = "0.4"
2827
mime = "0.3.13"
2928
once_cell = "1.18.0"

streams/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ name = "servo_media_streams"
1010
path = "lib.rs"
1111

1212
[dependencies]
13-
lazy_static = "1.0"
1413
uuid = { version = "1.4", features = ["v4"] }

streams/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#[macro_use]
2-
extern crate lazy_static;
3-
41
pub mod capture;
52
pub mod device_monitor;
63
pub mod registry;

streams/registry.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use super::MediaStream;
22
use std::collections::HashMap;
3-
use std::sync::{Arc, Mutex};
3+
use std::sync::{Arc, LazyLock, Mutex};
44
use uuid::Uuid;
55

6-
lazy_static! {
7-
static ref MEDIA_STREAMS_REGISTRY: Mutex<HashMap<MediaStreamId, Arc<Mutex<dyn MediaStream>>>> =
8-
Mutex::new(HashMap::new());
9-
}
6+
type RegisteredMediaStream = Arc<Mutex<dyn MediaStream>>;
7+
8+
static MEDIA_STREAMS_REGISTRY: LazyLock<Mutex<HashMap<MediaStreamId, RegisteredMediaStream>>> = LazyLock::new(|| {
9+
Mutex::new(HashMap::new())
10+
});
1011

1112
#[derive(Clone, Copy, Hash, Eq, PartialEq)]
1213
pub struct MediaStreamId(Uuid);

webrtc/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ edition = "2021"
99
path = "lib.rs"
1010

1111
[dependencies]
12-
lazy_static = "1.0"
13-
log = "0.4.6"
12+
log = "0.4"
1413
uuid = { version = "1.4", features = ["v4"] }
1514

1615
[dependencies.servo-media-streams]

0 commit comments

Comments
 (0)