refactor: remove lazy_static crate

The `lazy_static` crate was superseded by the `once_cell` crate which
has been included in Rust's standard library since version `1.70`.
Remove the `lazy_static` dependency and refactor all use cases to use
`std::sync::OnceLock` instead.

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
Thomas Frans
2023-10-07 17:33:48 +02:00
committed by GitHub
parent 2f365c1551
commit 209d8e260b
9 changed files with 30 additions and 28 deletions

View File

@@ -71,7 +71,7 @@ impl Spotify {
let (user_tx, user_rx) = oneshot::channel();
spotify.start_worker(Some(user_tx));
spotify.user = ASYNC_RUNTIME.block_on(user_rx).ok();
spotify.user = ASYNC_RUNTIME.get().unwrap().block_on(user_rx).ok();
let volume = cfg.state().volume;
spotify.set_volume(volume);
@@ -95,7 +95,7 @@ impl Spotify {
let events = self.events.clone();
let volume = self.volume();
let credentials = self.credentials.clone();
ASYNC_RUNTIME.spawn(Self::worker(
ASYNC_RUNTIME.get().unwrap().spawn(Self::worker(
worker_channel,
events,
rx,
@@ -122,6 +122,8 @@ impl Spotify {
pub fn test_credentials(credentials: Credentials) -> Result<Session, SessionError> {
let config = Self::session_config();
ASYNC_RUNTIME
.get()
.unwrap()
.block_on(Session::connect(config, credentials, None, true))
.map(|r| r.0)
}