Skip to content

Commit 45da69f

Browse files
committed
use LazyLock instead of the lazy_static
1 parent 1ee0333 commit 45da69f

File tree

6 files changed

+11
-20
lines changed

6 files changed

+11
-20
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,5 @@ anyhow = { version = "1.0", features = ["backtrace"] }
1616
tracing = "0.1"
1717

1818
# json
19-
serde = { version = "1", features = ["derive"] }
20-
serde_json = { version = "1" }
21-
22-
strum = { version = "0.26", features = ["derive"] }
23-
strum_macros = "0.26"
2419

2520
derive_more = { version = "1", features = ["full"] }
26-
derive-new = "0.7"

src/uactor/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "uactor"
3-
version = "0.14.1"
3+
version = "0.15.0"
44
edition = "2021"
55
repository = "https://github.com/EnvOut/uactor"
66
license = "MIT"
@@ -18,7 +18,6 @@ tracing = { workspace = true }
1818
paste = "1.0"
1919
derive_more = { workspace = true }
2020
bytes = { version = "1", optional = true }
21-
lazy_static = "1.5.0"
2221

2322
[dev-dependencies]
2423
more-asserts = "0.3.1"

src/uactor/src/actor/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ pub trait ActorContext: Sized + Unpin + 'static {
1717
Ok(())
1818
}
1919
#[inline]
20-
fn after_iteration(&mut self) -> () {}
20+
fn after_iteration(&mut self) {}
2121
#[inline]
22-
fn on_error(&mut self, _error: &HandleError) -> () {}
22+
fn on_error(&mut self, _error: &HandleError) {}
2323
fn kill(&mut self);
2424
fn get_name(&self) -> &str;
2525
#[allow(clippy::wrong_self_convention)]
@@ -233,7 +233,7 @@ pub mod extensions {
233233
/// ```
234234
#[inline]
235235
pub fn is_empty(&self) -> bool {
236-
self.map.as_ref().map_or(true, |map| map.is_empty())
236+
self.map.as_ref().is_none_or(|map| map.is_empty())
237237
}
238238

239239
/// Get the number of extensions available.

src/uactor/src/data/datasource_combinators/filter_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ where
4646
F: Fn(&D::Item) -> bool + Send,
4747
D: DataSource + Send,
4848
{
49+
#[allow(dead_code)]
4950
fn map(self, map_fn: F) -> DataSourceFilter<D, F>;
5051
}
5152

src/uactor/src/system/global.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::sync::Arc;
1+
use std::sync::{Arc, LazyLock};
22
use tokio::sync::mpsc::UnboundedSender;
33
use tokio::sync::RwLock;
44
use tokio::task::JoinHandle;
@@ -10,11 +10,9 @@ use crate::dependency_injection::Inject;
1010
use crate::system::builder::SystemBuilder;
1111
use super::{ActorRunningError, System};
1212

13-
lazy_static::lazy_static! {
14-
static ref GLOBAL_SYSTEM: Arc<RwLock<System>> = {
15-
Arc::new(RwLock::new(SystemBuilder::new_global().build()))
16-
};
17-
}
13+
static GLOBAL_SYSTEM: LazyLock<Arc<RwLock<System>>> = LazyLock::new(|| {
14+
Arc::new(RwLock::new(SystemBuilder::new_global().build()))
15+
});
1816

1917
pub struct GlobalSystem {}
2018

@@ -66,7 +64,7 @@ impl GlobalSystem {
6664

6765
pub async fn with(&mut self, with: impl FnOnce(&mut System)) -> Self {
6866
let mut system = GLOBAL_SYSTEM.write().await;
69-
with(&mut *system);
67+
with(&mut system);
7068
GlobalSystem {}
7169
}
7270
}

0 commit comments

Comments
 (0)