summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2023-06-21 16:40:37 +0200
committerMarkus Pettersson <markus.pettersson@mullvad.net>2023-08-04 09:55:36 +0200
commit6d646cf7f5d54377deaa95b8e71d5400116d68b3 (patch)
tree17a743c438260dde344111ba82fb26502bcb7ab9
parentc1ac80e985e92a74cc580fd85b2e4f5b57c8c96d (diff)
downloadmullvadvpn-6d646cf7f5d54377deaa95b8e71d5400116d68b3.tar.xz
mullvadvpn-6d646cf7f5d54377deaa95b8e71d5400116d68b3.zip
Remove some use of `once_cell` with new std alternatives
`OnceCell` and `OnceLock` was stabilized in Rust `1.70.0`, which allow us to refactor some use of the `once_cell` crate to use the implementations in the standard library.
-rw-r--r--mullvad-api/src/lib.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs
index e304df1dec..993d6e94a0 100644
--- a/mullvad-api/src/lib.rs
+++ b/mullvad-api/src/lib.rs
@@ -9,7 +9,7 @@ use mullvad_types::{
account::{AccountToken, VoucherSubmission},
version::AppVersion,
};
-use once_cell::sync::OnceCell;
+use std::sync::OnceLock;
use proxy::ApiConnectionMode;
use std::{
cell::Cell,
@@ -66,18 +66,18 @@ const APP_URL_PREFIX: &str = "app/v1";
pub static API: LazyManual<ApiEndpoint> = LazyManual::new(ApiEndpoint::from_env_vars);
-unsafe impl<T, F: Send> Sync for LazyManual<T, F> where OnceCell<T>: Sync {}
+unsafe impl<T, F: Send> Sync for LazyManual<T, F> where OnceLock<T>: Sync {}
/// A value that is either initialized on access or explicitly.
pub struct LazyManual<T, F = fn() -> T> {
- cell: OnceCell<T>,
+ cell: OnceLock<T>,
lazy_fn: Cell<Option<F>>,
}
impl<T, F> LazyManual<T, F> {
const fn new(lazy_fn: F) -> Self {
Self {
- cell: OnceCell::new(),
+ cell: OnceLock::new(),
lazy_fn: Cell::new(Some(lazy_fn)),
}
}