replace lazy_static uses with once_cell (#1391)

This commit is contained in:
chip
2021-03-25 17:50:24 -07:00
committed by GitHub
parent 080f6391ba
commit b79462e5cc
3 changed files with 6 additions and 11 deletions

View File

@@ -21,7 +21,6 @@ features = [ "api-all" ]
serde_json = "1.0"
serde = { version = "1.0", features = [ "derive" ] }
base64 = "0.13.0"
lazy_static = "1.4.0"
tokio = { version = "1.4", features = ["rt", "rt-multi-thread", "sync"] }
futures = "0.3"
async-trait = "0.1"

View File

@@ -5,10 +5,10 @@ use std::{
};
use crate::ApplicationDispatcherExt;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use serde::Serialize;
use serde_json::Value as JsonValue;
use uuid::Uuid;
/// Event identifier.
pub type EventId = u64;
@@ -25,11 +25,9 @@ struct EventHandler {
type Listeners = Arc<Mutex<HashMap<String, Vec<EventHandler>>>>;
lazy_static! {
static ref EMIT_FUNCTION_NAME: String = uuid::Uuid::new_v4().to_string();
static ref EVENT_LISTENERS_OBJECT_NAME: String = uuid::Uuid::new_v4().to_string();
static ref EVENT_QUEUE_OBJECT_NAME: String = uuid::Uuid::new_v4().to_string();
}
static EMIT_FUNCTION_NAME: Lazy<String> = Lazy::new(|| Uuid::new_v4().to_string());
static EVENT_LISTENERS_OBJECT_NAME: Lazy<String> = Lazy::new(|| Uuid::new_v4().to_string());
static EVENT_QUEUE_OBJECT_NAME: Lazy<String> = Lazy::new(|| Uuid::new_v4().to_string());
/// Gets the listeners map.
fn listeners() -> &'static Listeners {

View File

@@ -1,6 +1,6 @@
use std::sync::Mutex;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use uuid::Uuid;
/// A salt definition.
@@ -9,9 +9,7 @@ struct Salt {
one_time: bool,
}
lazy_static! {
static ref SALTS: Mutex<Vec<Salt>> = Mutex::new(vec![]);
}
static SALTS: Lazy<Mutex<Vec<Salt>>> = Lazy::new(Mutex::default);
/// Generates a one time Salt and returns its string representation.
pub fn generate() -> String {