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

@ -1,7 +1,7 @@
[package]
name = "cosmic-theme"
version = "0.1.0"
edition = "2021"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -22,7 +22,6 @@ serde_json = { version = "1.0.143", optional = true, features = [
"preserve_order",
] }
ron = "0.11.0"
lazy_static = "1.5.0"
csscolorparser = { version = "0.7.2", features = ["serde"] }
cosmic-config = { path = "../cosmic-config/", default-features = false, features = [
"subscription",

View file

@ -1,15 +1,14 @@
use lazy_static::lazy_static;
use palette::Srgba;
use serde::{Deserialize, Serialize};
use std::sync::LazyLock;
lazy_static! {
/// built in light palette
pub static ref LIGHT_PALETTE: CosmicPalette =
ron::from_str(include_str!("light.ron")).unwrap();
/// built in dark palette
pub static ref DARK_PALETTE: CosmicPalette =
ron::from_str(include_str!("dark.ron")).unwrap();
}
/// built-in light palette
pub static LIGHT_PALETTE: LazyLock<CosmicPalette> =
LazyLock::new(|| ron::from_str(include_str!("light.ron")).unwrap());
/// built-in dark palette
pub static DARK_PALETTE: LazyLock<CosmicPalette> =
LazyLock::new(|| ron::from_str(include_str!("dark.ron")).unwrap());
/// Palette type
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]

View file

@ -1,12 +1,12 @@
use crate::{
Component, Container, CornerRadii, CosmicPalette, CosmicPaletteInner, DARK_PALETTE,
LIGHT_PALETTE, NAME, Spacing, ThemeMode,
composite::over,
steps::{color_index, get_small_widget_color, get_surface_color, get_text, steps},
Component, Container, CornerRadii, CosmicPalette, CosmicPaletteInner, Spacing, ThemeMode,
DARK_PALETTE, LIGHT_PALETTE, NAME,
};
use cosmic_config::{Config, CosmicConfigEntry};
use palette::{
color_difference::Wcag21RelativeContrast, rgb::Rgb, IntoColor, Oklcha, Srgb, Srgba, WithAlpha,
IntoColor, Oklcha, Srgb, Srgba, WithAlpha, color_difference::Wcag21RelativeContrast, rgb::Rgb,
};
use serde::{Deserialize, Serialize};
use std::num::NonZeroUsize;

View file

@ -1,5 +1,5 @@
use crate::{composite::over, steps::steps, Component, Theme};
use palette::{rgb::Rgba, Darken, IntoColor, Lighten, Srgba, WithAlpha};
use crate::{Component, Theme, composite::over, steps::steps};
use palette::{Darken, IntoColor, Lighten, Srgba, WithAlpha, rgb::Rgba};
use std::{
fs::{self, File},
io::{self, Write},
@ -7,7 +7,7 @@ use std::{
path::Path,
};
use super::{to_rgba, OutputError};
use super::{OutputError, to_rgba};
impl Theme {
#[must_use]

View file

@ -1,4 +1,4 @@
use palette::{rgb::Rgba, Srgba};
use palette::{Srgba, rgb::Rgba};
use thiserror::Error;
use crate::Theme;

View file

@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use crate::Theme;
use super::{to_hex, OutputError};
use super::{OutputError, to_hex};
/// Represents the workbench.colorCustomizations section of a VS Code settings.json file
#[derive(Debug, Clone, Serialize, Deserialize)]

View file

@ -1,7 +1,7 @@
use std::num::NonZeroUsize;
use almost::equal;
use palette::{convert::FromColorUnclamped, ClampAssign, FromColor, Lch, Oklcha, Srgb, Srgba};
use palette::{ClampAssign, FromColor, Lch, Oklcha, Srgb, Srgba, convert::FromColorUnclamped};
/// Get an array of 100 colors with a specific hue and chroma
/// over the full range of lightness.