Skip to main content

write_declarations

Function write_declarations 

Source
pub fn write_declarations<T: Copy, V: Display>(
    out: &mut String,
    items: &[T],
    token: impl Fn(T) -> &'static str,
    value: impl Fn(T) -> V,
)
Expand description

Append one --token: value; line per item, indented two spaces.

The one spelling of a custom-property declaration in a generated :root block, for this crate’s emitters and for any sibling crate that emits an axis of its own into the same block.

let mut out = String::new();
write_declarations(&mut out, Stroke::all(), Stroke::token, Stroke::css);
assert_eq!(out, "  --stroke-hairline: 1px;\n  --stroke-mark: 2px;\n");