Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ members = ["color", "color_operations"]
# version in the `workspace.dependencies` section in this file.
version = "0.3.3"

edition = "2021"
edition = "2024"
# Keep in sync with RUST_MIN_VER in .github/workflows/ci.yml, with the relevant README.md files
# and with the MSRV in the `Unreleased` section of CHANGELOG.md.
rust-version = "1.86"
Expand Down
2 changes: 1 addition & 1 deletion color/examples/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! cargo run --example gradient 'oklab(0.5 0.2 0)' 'rgb(0, 200, 0, 0.8)' oklab
//! ```

use color::{gradient, ColorSpaceTag, DynamicColor, GradientIter, HueDirection, Srgb};
use color::{ColorSpaceTag, DynamicColor, GradientIter, HueDirection, Srgb, gradient};

fn main() {
let mut args = std::env::args().skip(1);
Expand Down
6 changes: 1 addition & 5 deletions color/make_x11_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,5 @@ def minimal_perfect_hash(d):
}
let salt = SALTS[weak_hash(key, 0, SALTS.len())] as u32;
let ix = weak_hash(key, salt, SALTS.len());
if s == NAMES[ix] {
Some(ix)
} else {
None
}
if s == NAMES[ix] { Some(ix) } else { None }
}""")
2 changes: 1 addition & 1 deletion color/src/cache_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<T: BitEq> BitEq for &T {
mod tests {
extern crate std;
use super::CacheKey;
use crate::{parse_color, DynamicColor};
use crate::{DynamicColor, parse_color};
use std::collections::HashMap;

#[test]
Expand Down
6 changes: 3 additions & 3 deletions color/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use core::any::TypeId;
use core::marker::PhantomData;

use crate::{
cache_key::{BitEq, BitHash},
ColorSpace, ColorSpaceLayout, ColorSpaceTag, Oklab, Oklch, PremulRgba8, Rgba8, Srgb,
cache_key::{BitEq, BitHash},
};

#[cfg(all(not(feature = "std"), not(test)))]
Expand Down Expand Up @@ -969,8 +969,8 @@ mod tests {
extern crate alloc;

use super::{
fast_round_to_u8, fixup_hue, AlphaColor, HueDirection, PremulColor, PremulRgba8, Rgba8,
Srgb,
AlphaColor, HueDirection, PremulColor, PremulRgba8, Rgba8, Srgb, fast_round_to_u8,
fixup_hue,
};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion color/src/colorspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate std;

use core::any::TypeId;

use crate::{matvecmul, tag::ColorSpaceTag, Chromaticity};
use crate::{Chromaticity, matvecmul, tag::ColorSpaceTag};

#[cfg(all(not(feature = "std"), not(test)))]
use crate::floatfuncs::FloatFuncs;
Expand Down
6 changes: 3 additions & 3 deletions color/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//! CSS colors and syntax.

use crate::{
cache_key::{BitEq, BitHash},
color::{add_alpha, fixup_hues_for_interpolate, split_alpha, InterpolationAlphaSpace},
AlphaColor, Chromaticity, ColorSpace, ColorSpaceLayout, ColorSpaceTag, Flags, HueDirection,
LinearSrgb, Missing,
cache_key::{BitEq, BitHash},
color::{InterpolationAlphaSpace, add_alpha, fixup_hues_for_interpolate, split_alpha},
};
use core::hash::{Hash, Hasher};

Expand Down Expand Up @@ -650,7 +650,7 @@ impl UnpremultipliedInterpolator {

#[cfg(test)]
mod tests {
use crate::{parse_color, ColorSpaceTag, DynamicColor, Missing};
use crate::{ColorSpaceTag, DynamicColor, Missing, parse_color};

// `DynamicColor` was carefully packed. Ensure its size doesn't accidentally change.
const _: () = if size_of::<DynamicColor>() != 20 {
Expand Down
10 changes: 5 additions & 5 deletions color/src/impl_bytemuck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#![expect(unsafe_code, reason = "unsafe is required for bytemuck unsafe impls")]

use crate::{
cache_key::CacheKey, AlphaColor, ColorSpace, ColorSpaceTag, HueDirection, OpaqueColor,
PremulColor, PremulRgba8, Rgba8,
AlphaColor, ColorSpace, ColorSpaceTag, HueDirection, OpaqueColor, PremulColor, PremulRgba8,
Rgba8, cache_key::CacheKey,
};

// Safety: The struct is `repr(transparent)` and the data member is bytemuck::Pod.
Expand Down Expand Up @@ -103,10 +103,10 @@ unsafe impl<T> bytemuck::TransparentWrapper<T> for CacheKey<T> {}
#[cfg(test)]
mod tests {
use crate::{
cache_key::CacheKey, AlphaColor, ColorSpaceTag, HueDirection, OpaqueColor, PremulColor,
PremulRgba8, Rgba8, Srgb,
AlphaColor, ColorSpaceTag, HueDirection, OpaqueColor, PremulColor, PremulRgba8, Rgba8,
Srgb, cache_key::CacheKey,
};
use bytemuck::{checked::try_from_bytes, Contiguous, TransparentWrapper, Zeroable};
use bytemuck::{Contiguous, TransparentWrapper, Zeroable, checked::try_from_bytes};
use core::{marker::PhantomData, ptr};

fn assert_is_pod(_pod: impl bytemuck::Pod) {}
Expand Down
4 changes: 2 additions & 2 deletions color/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ pub use colorspace::{
};
pub use dynamic::{DynamicColor, Interpolator, UnpremultipliedInterpolator};
pub use flags::{Flags, Missing};
pub use gradient::{gradient, gradient_unpremultiplied, GradientIter, UnpremultipliedGradientIter};
pub use parse::{parse_color, parse_color_prefix, ParseError};
pub use gradient::{GradientIter, UnpremultipliedGradientIter, gradient, gradient_unpremultiplied};
pub use parse::{ParseError, parse_color, parse_color_prefix};
pub use rgba8::{PremulRgba8, Rgba8};
pub use tag::ColorSpaceTag;

Expand Down
14 changes: 9 additions & 5 deletions color/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ fn make_lowercase<'a>(s: &'a str, buf: &'a mut [u8; LOWERCASE_BUF_SIZE]) -> &'a
mod tests {
use crate::DynamicColor;

use super::{parse_color, parse_color_prefix, Mode, ParseError, Parser};
use super::{Mode, ParseError, Parser, parse_color, parse_color_prefix};

fn assert_close_color(c1: DynamicColor, c2: DynamicColor) {
const EPSILON: f32 = 1e-4;
Expand Down Expand Up @@ -797,8 +797,10 @@ mod tests {
] {
let mut parser = Parser::new(alpha);
let result = parser.alpha(mode);
assert_eq!(result, expected,
"Failed parsing specified alpha `{alpha}`. Expected: `{expected:?}`. Got: `{result:?}`.");
assert_eq!(
result, expected,
"Failed parsing specified alpha `{alpha}`. Expected: `{expected:?}`. Got: `{result:?}`."
);
}
}

Expand All @@ -812,8 +814,10 @@ mod tests {
] {
let mut parser = Parser::new(angle);
let result = parser.angle().unwrap().unwrap();
assert!((result - expected).abs() < 1e-4,
"Failed parsing specified angle `{angle}`. Expected: `{expected:?}`. Got: `{result:?}`.");
assert!(
(result - expected).abs() < 1e-4,
"Failed parsing specified angle `{angle}`. Expected: `{expected:?}`. Got: `{result:?}`."
);
}

{
Expand Down
11 changes: 4 additions & 7 deletions color/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl core::fmt::UpperHex for Rgba8 {
mod tests {
extern crate alloc;

use crate::{parse_color, AlphaColor, DynamicColor, Hsl, Oklab, Srgb, XyzD65};
use crate::{AlphaColor, DynamicColor, Hsl, Oklab, Srgb, XyzD65, parse_color};
use alloc::format;

#[test]
Expand Down Expand Up @@ -187,8 +187,7 @@ mod tests {
] {
let result = format!("{}", parse_color(specified).unwrap());
assert_eq!(
result,
expected,
result, expected,
"Failed serializing specified color `{specified}`. Expected: `{expected}`. Got: `{result}`."
);
}
Expand Down Expand Up @@ -234,8 +233,7 @@ mod tests {
] {
let result = format!("{color}");
assert_eq!(
result,
expected,
result, expected,
"Failed serializing specified color `{color}`. Expected: `{expected}`. Got: `{result}`."
);
}
Expand All @@ -246,8 +244,7 @@ mod tests {
for name in crate::x11_colors::NAMES {
let result = format!("{}", parse_color(name).unwrap());
assert_eq!(
result,
name,
result, name,
"Failed serializing specified named color `{name}`. Expected it to roundtrip. Got: `{result}`."
);
}
Expand Down
6 changes: 1 addition & 5 deletions color/src/x11_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,5 @@ pub(crate) fn lookup_palette_index(s: &str) -> Option<usize> {
}
let salt = SALTS[weak_hash(key, 0, SALTS.len())] as u32;
let ix = weak_hash(key, salt, SALTS.len());
if s == NAMES[ix] {
Some(ix)
} else {
None
}
if s == NAMES[ix] { Some(ix) } else { None }
}
Loading