css!() { /* proc-macro */ }Expand description
css!(name: value, …) — kwarg syntax for the Css builder.
Lowers to a Css::new() method chain (Css::new().name(value) .…). Css is taken from the call site’s scope, so
use whisker::prelude::* (which re-exports Css) is the only
import callers need.
The proc-macro implementation tolerates partial input from
rust-analyzer’s completion engine: a kwarg whose value hasn’t
been typed yet (css!(back|) is expanded as
.<name>(()) so RA still sees a real method-call site and
fires its method-name completion. The unit () is intentionally
type-incorrect; the program already doesn’t compile while the
user is mid-typing.
ⓘ
use whisker::prelude::*;
let s = css!(
background_color: Color::hex(0x1A1330),
padding: (px(8), px(16)),
border: Border::new().width(px(1)).style(BorderStyle::Solid),
);