Skip to content

Commit e9fb333

Browse files
authored
Merge pull request #129 from fenollp/drop--once_cell
deps: drop once_cell with MSRV=1.80
2 parents 2864dc6 + 719c7bf commit e9fb333

File tree

9 files changed

+39
-37
lines changed

9 files changed

+39
-37
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ edition = "2021"
1111

1212
[dependencies]
1313
log = "0.4.22"
14-
once_cell = "1.19.0"
1514
cgmath = "0.18.0"
1615
libc = "0.2.69"
1716

examples/demo.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ use libremarkable::stopwatch;
1717

1818
use chrono::{DateTime, Local};
1919
use log::info;
20-
use once_cell::sync::Lazy;
2120

2221
use std::collections::VecDeque;
2322
use std::fmt;
2423
use std::process::Command;
2524
use std::sync::atomic::{AtomicBool, AtomicI32, AtomicU8, Ordering};
26-
use std::sync::Mutex;
25+
use std::sync::{LazyLock, Mutex};
2726
use std::thread::sleep;
2827
use std::time::Duration;
2928

@@ -141,16 +140,17 @@ const CANVAS_REGION: mxcfb_rect = mxcfb_rect {
141140

142141
type PointAndPressure = (cgmath::Point2<f32>, i32);
143142

144-
static G_TOUCH_MODE: Lazy<AtomicU8> = Lazy::new(|| AtomicU8::new(TouchMode::OnlyUI.into()));
145-
static G_DRAW_MODE: Lazy<AtomicI32> = Lazy::new(|| AtomicI32::new(DrawMode::Draw(2).into()));
146-
static UNPRESS_OBSERVED: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
147-
static WACOM_IN_RANGE: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
148-
static WACOM_RUBBER_SIDE: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
149-
static WACOM_HISTORY: Lazy<Mutex<VecDeque<PointAndPressure>>> =
150-
Lazy::new(|| Mutex::new(VecDeque::new()));
151-
static G_COUNTER: Lazy<Mutex<u32>> = Lazy::new(|| Mutex::new(0));
152-
static SAVED_CANVAS: Lazy<Mutex<Option<storage::CompressedCanvasState>>> =
153-
Lazy::new(|| Mutex::new(None));
143+
static G_TOUCH_MODE: LazyLock<AtomicU8> = LazyLock::new(|| AtomicU8::new(TouchMode::OnlyUI.into()));
144+
static G_DRAW_MODE: LazyLock<AtomicI32> =
145+
LazyLock::new(|| AtomicI32::new(DrawMode::Draw(2).into()));
146+
static UNPRESS_OBSERVED: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
147+
static WACOM_IN_RANGE: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
148+
static WACOM_RUBBER_SIDE: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
149+
static WACOM_HISTORY: LazyLock<Mutex<VecDeque<PointAndPressure>>> =
150+
LazyLock::new(|| Mutex::new(VecDeque::new()));
151+
static G_COUNTER: LazyLock<Mutex<u32>> = LazyLock::new(|| Mutex::new(0));
152+
static SAVED_CANVAS: LazyLock<Mutex<Option<storage::CompressedCanvasState>>> =
153+
LazyLock::new(|| Mutex::new(None));
154154

155155
// ####################
156156
// ## Button Handlers

examples/spy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ use std::sync::Mutex;
33

44
use libc::c_int;
55
use libc::intptr_t;
6-
use once_cell::sync::Lazy;
76
use redhook::{hook, real};
7+
use std::sync::LazyLock;
88

99
use libremarkable::framebuffer::common::*;
1010
use libremarkable::framebuffer::mxcfb::*;
1111
use libremarkable::framebuffer::screeninfo::VarScreeninfo;
1212

13-
static DIST_DITHER: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
13+
static DIST_DITHER: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
1414
let m = HashMap::new();
1515
Mutex::new(m)
1616
});
17-
static DIST_WAVEFORM: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
17+
static DIST_WAVEFORM: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
1818
let m = HashMap::new();
1919
Mutex::new(m)
2020
});
21-
static DIST_QUANT: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
21+
static DIST_QUANT: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
2222
let m = HashMap::new();
2323
Mutex::new(m)
2424
});
25-
static DIST_FLAGS: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
25+
static DIST_FLAGS: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
2626
let m = HashMap::new();
2727
Mutex::new(m)
2828
});
29-
static DIST_TEMP: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
29+
static DIST_TEMP: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
3030
let m = HashMap::new();
3131
Mutex::new(m)
3232
});

src/device/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use once_cell::sync::Lazy;
21
use rotate::InputDeviceRotation;
2+
use std::sync::LazyLock;
33

44
/// Utility for rotating
55
pub mod rotate;
@@ -52,7 +52,7 @@ impl Model {
5252
}
5353
}
5454

55-
pub static CURRENT_DEVICE: Lazy<Device> = Lazy::new(Device::new);
55+
pub static CURRENT_DEVICE: LazyLock<Device> = LazyLock::new(Device::new);
5656

5757
/// Differentiate between the reasons why the determination of the current device model can fail.
5858
#[derive(Debug)]

src/dimensions.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#[cfg(feature = "input")]
22
use crate::input::scan::SCANNED;
33
#[cfg(feature = "input")]
4-
use once_cell::sync::Lazy;
4+
use std::sync::LazyLock;
55

66
pub const DISPLAYWIDTH: u16 = 1404;
77
pub const DISPLAYHEIGHT: u16 = 1872;
88

99
/// Will be 767 rM1 and 1403 on the rM2
1010
#[cfg(feature = "input")]
11-
pub static MTWIDTH: Lazy<u16> = Lazy::new(|| SCANNED.mt_width);
11+
pub static MTWIDTH: LazyLock<u16> = LazyLock::new(|| SCANNED.mt_width);
1212
/// Will be 1023 the rM1 and 1871 on the rM2
1313
#[cfg(feature = "input")]
14-
pub static MTHEIGHT: Lazy<u16> = Lazy::new(|| SCANNED.mt_height);
14+
pub static MTHEIGHT: LazyLock<u16> = LazyLock::new(|| SCANNED.mt_height);
1515

1616
/// Will be 15725 on both the rM1 and rM2
1717
#[cfg(feature = "input")]
18-
pub static WACOMWIDTH: Lazy<u16> = Lazy::new(|| SCANNED.wacom_width);
18+
pub static WACOMWIDTH: LazyLock<u16> = LazyLock::new(|| SCANNED.wacom_width);
1919
/// Will be 20967 on the rM1 and 20966 on the rM2
2020
#[cfg(feature = "input")]
21-
pub static WACOMHEIGHT: Lazy<u16> = Lazy::new(|| SCANNED.wacom_height);
21+
pub static WACOMHEIGHT: LazyLock<u16> = LazyLock::new(|| SCANNED.wacom_height);

src/framebuffer/draw.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#[cfg(feature = "image")]
22
use image::RgbImage;
33

4-
#[cfg(feature = "framebuffer-text-drawing")]
5-
use once_cell::sync::Lazy;
64
#[cfg(feature = "framebuffer-text-drawing")]
75
use rusttype::{point, Font, Scale};
6+
#[cfg(feature = "framebuffer-text-drawing")]
7+
use std::sync::LazyLock;
88

99
use crate::framebuffer;
1010
use crate::framebuffer::cgmath::*;
@@ -14,7 +14,7 @@ use crate::framebuffer::graphics;
1414
use crate::framebuffer::FramebufferIO;
1515

1616
#[cfg(feature = "framebuffer-text-drawing")]
17-
pub static DEFAULT_FONT: Lazy<Font<'static>> = Lazy::new(|| {
17+
pub static DEFAULT_FONT: LazyLock<Font<'static>> = LazyLock::new(|| {
1818
Font::try_from_bytes(include_bytes!("../../assets/Roboto-Regular.ttf").as_slice())
1919
.expect("corrupted font data")
2020
});

src/input/multitouch.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::device::CURRENT_DEVICE;
44
use crate::dimensions::{DISPLAYHEIGHT, DISPLAYWIDTH, MTHEIGHT, MTWIDTH};
55
use crate::input::scan::SCANNED;
66
use crate::input::{Finger, InputDeviceState, InputEvent, MultitouchEvent};
7-
use once_cell::sync::Lazy;
7+
use std::sync::LazyLock;
88

99
use evdev::InputEvent as EvInputEvent;
1010
use fxhash::FxHashMap;
@@ -14,8 +14,9 @@ use std::sync::{
1414
Mutex,
1515
};
1616

17-
static MT_HSCALAR: Lazy<f32> = Lazy::new(|| f32::from(DISPLAYWIDTH) / f32::from(*MTWIDTH));
18-
static MT_VSCALAR: Lazy<f32> = Lazy::new(|| f32::from(DISPLAYHEIGHT) / f32::from(*MTHEIGHT));
17+
static MT_HSCALAR: LazyLock<f32> = LazyLock::new(|| f32::from(DISPLAYWIDTH) / f32::from(*MTWIDTH));
18+
static MT_VSCALAR: LazyLock<f32> =
19+
LazyLock::new(|| f32::from(DISPLAYHEIGHT) / f32::from(*MTHEIGHT));
1920

2021
pub struct MultitouchState {
2122
fingers: Mutex<FxHashMap<i32 /* slot */, Finger>>,

src/input/scan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ use super::ecodes;
22
use super::InputDevice;
33
use cgmath::Vector2;
44
use log::debug;
5-
use once_cell::sync::Lazy;
65
use std::path::{Path, PathBuf};
6+
use std::sync::LazyLock;
77
use std::sync::{Arc, Mutex};
88
use std::time::Duration;
99

1010
pub const INITIAL_DEVS_AVAILABLE_FOR: Duration = Duration::from_millis(150);
1111

1212
/// A singleton of the EvDevsScan object
13-
pub static SCANNED: Lazy<EvDevs> = Lazy::new(EvDevs::new);
13+
pub static SCANNED: LazyLock<EvDevs> = LazyLock::new(EvDevs::new);
1414

1515
/// This struct contains the results of initially scaning all evdev devices,
1616
/// which allows for device model independancy.

src/input/wacom.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ use crate::input::scan::SCANNED;
55
use crate::input::{InputDeviceState, InputEvent, WacomEvent, WacomPen};
66
use evdev::InputEvent as EvInputEvent;
77
use log::debug;
8-
use once_cell::sync::Lazy;
98
use std::sync::atomic::{AtomicBool, AtomicU16, Ordering};
9+
use std::sync::LazyLock;
1010

1111
use crate::cgmath;
1212
use crate::dimensions::{DISPLAYHEIGHT, DISPLAYWIDTH, WACOMHEIGHT, WACOMWIDTH};
1313

14-
static WACOM_HSCALAR: Lazy<f32> = Lazy::new(|| f32::from(DISPLAYWIDTH) / f32::from(*WACOMWIDTH));
15-
static WACOM_VSCALAR: Lazy<f32> = Lazy::new(|| f32::from(DISPLAYHEIGHT) / f32::from(*WACOMHEIGHT));
14+
static WACOM_HSCALAR: LazyLock<f32> =
15+
LazyLock::new(|| f32::from(DISPLAYWIDTH) / f32::from(*WACOMWIDTH));
16+
static WACOM_VSCALAR: LazyLock<f32> =
17+
LazyLock::new(|| f32::from(DISPLAYHEIGHT) / f32::from(*WACOMHEIGHT));
1618

1719
pub struct WacomState {
1820
last_x: AtomicU16,

0 commit comments

Comments
 (0)