Skip to content

Commit f23d3fc

Browse files
committed
Use std::sync::LazyLock instead of once_cell::Lazy
Generally better to use the library standard facility rather than an external crate where possible. LazyLock was introduced in version 1.80.0 of the Rust standard library. Signed-off-by: mulhern <amulhern@redhat.com>
1 parent 3649845 commit f23d3fc

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

‎Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ serde = "1.0.60"
2323
rand = "0.9.0"
2424
retry = {version = "2.0.0", default-features=false}
2525
log = "0.4.14"
26-
once_cell = "1.19.0"
2726

2827
[dev-dependencies]
2928
assert_matches = "1.5.0"

‎src/core/dm_ioctl.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
use std::collections::HashMap;
6-
7-
use once_cell::sync::Lazy;
6+
use std::sync::LazyLock;
87

98
pub use devicemapper_sys::{
109
dm_ioctl as Struct_dm_ioctl, dm_name_list as Struct_dm_name_list,
@@ -15,7 +14,7 @@ pub use devicemapper_sys::{
1514
// Map device-mapper ioctl commands to the minimum ioctl interface version
1615
// required. The mapping is based on the _cmd_data_v4 table defined in
1716
// libdm/ioctl/libdm-iface.c in the lvm2/libdevmapper sources.
18-
static IOCTL_VERSIONS: Lazy<HashMap<u32, (u32, u32, u32)>> = Lazy::new(|| {
17+
static IOCTL_VERSIONS: LazyLock<HashMap<u32, (u32, u32, u32)>> = LazyLock::new(|| {
1918
HashMap::from([
2019
(DM_VERSION_CMD, (4, 0, 0)),
2120
(DM_REMOVE_ALL_CMD, (4, 0, 0)),

‎src/core/dm_udev_sync.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ pub mod sync_semaphore {
3535

3636
use nix::unistd::{access, AccessFlags};
3737

38-
use once_cell::sync::Lazy;
39-
4038
use rand::Rng;
4139
use retry::{delay::NoDelay, retry, OperationResult};
42-
use std::{io, path::Path};
40+
use std::{io, path::Path, sync::LazyLock};
4341

4442
use crate::core::sysvsem::seminfo;
4543

@@ -63,7 +61,7 @@ pub mod sync_semaphore {
6361
}
6462
}
6563

66-
static SYSV_SEM_SUPPORTED: Lazy<bool> = Lazy::new(sysv_sem_supported);
64+
static SYSV_SEM_SUPPORTED: LazyLock<bool> = LazyLock::new(sysv_sem_supported);
6765

6866
/// Test whether the system is configured for SysV semaphore support.
6967
fn sysv_sem_supported() -> bool {

0 commit comments

Comments
 (0)