chore: use std::syncLazyLock

Also migrates workspace members to Rust 2024.
This commit is contained in:
Vukašin Vojinović 2025-09-03 20:22:06 +02:00 committed by Michael Murphy
parent b72b15d719
commit ea349aca82
15 changed files with 64 additions and 71 deletions

View file

@ -119,22 +119,14 @@ where
macro_rules! icon {
($name:expr, $on_press:expr) => {{
#[cfg(target_os = "linux")]
let icon = {
icon::from_name($name)
.apply(button::icon)
};
let icon = { icon::from_name($name).apply(button::icon) };
#[cfg(not(target_os = "linux"))]
let icon = {
icon::from_svg_bytes(include_bytes!(concat!(
"../../res/icons/",
$name,
".svg"
)))
.symbolic(true)
.apply(button::icon)
icon::from_svg_bytes(include_bytes!(concat!("../../res/icons/", $name, ".svg")))
.symbolic(true)
.apply(button::icon)
};
icon.padding([0, 12])
.on_press($on_press)
icon.padding([0, 12]).on_press($on_press)
}};
}
let date = text(this.model.visible.format("%B %Y").to_string()).size(18);

View file

@ -6,6 +6,7 @@
use std::borrow::Cow;
use std::iter;
use std::rc::Rc;
use std::sync::LazyLock;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::{Duration, Instant};
@ -26,7 +27,6 @@ use iced_core::{
use iced_widget::slider::HandleShape;
use iced_widget::{Row, canvas, column, horizontal_space, row, scrollable, vertical_space};
use lazy_static::lazy_static;
use palette::{FromColor, RgbHue};
use super::divider::horizontal;
@ -38,17 +38,17 @@ use super::{Icon, button, segmented_control, text, text_input, tooltip};
pub use ColorPickerModel as Model;
// TODO is this going to look correct enough?
lazy_static! {
pub static ref HSV_RAINBOW: Vec<iced::Color> = (0u16..8)
.map(
|h| iced::Color::from(palette::Srgba::from_color(palette::Hsv::new_srgb_const(
pub static HSV_RAINBOW: LazyLock<Vec<Color>> = LazyLock::new(|| {
(0u16..8)
.map(|h| {
Color::from(palette::Srgba::from_color(palette::Hsv::new_srgb_const(
RgbHue::new(f32::from(h) * 360.0 / 7.0),
1.0,
1.0
1.0,
)))
)
.collect();
}
})
.collect()
});
const MAX_RECENT: usize = 20;