MCPcopy Create free account
hub / github.com/csskit/csskit / shortest

Method shortest

crates/csskit_transform/src/reduce_colors.rs:30–39  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

28
29impl Shortest for chromashift::Color {
30 fn shortest(&self) -> Option<String> {
31 [
32 Some(Hex::from(*self).to_string()),
33 Named::try_from(*self).ok().map(|named| named.to_string()),
34 Some(Srgb::from(*self).round().to_string()),
35 ]
36 .into_iter()
37 .flatten()
38 .min_by(|a, b| a.len().cmp(&b.len()).then_with(|| a.cmp(b)))
39 }
40}
41
42/// Formats a CSS alpha value (0–1) from chromashift's internal 0–100 representation.

Callers 2

visit_colorMethod · 0.80

Calls 5

into_iterMethod · 0.80
okMethod · 0.80
roundMethod · 0.80
cmpMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected