Expand description
§webrust-macros — Proc-macros for WebRust
Provides the #[gui(...)] attribute and rewrites of print/println
to support:
- F-strings-like formatting:
println("Hello {user:?}, score={score:.2}") - Inline LaTeX with
$( ... )(preserved for the renderer) #[gui(Font, Size, color, !bg)]: boots the GUI server and applies theme
§#[gui(...)] Attribute
Compact, order-agnostic syntax:
- Font (capitalized tokens):
Arial,Times_New_Roman→ spaces restored - Size:
14px,16px, … - Text color:
black,#222,crimson, … - Background:
!white,!#f8fafc, …
Example:
use webrust::prelude::*;
#[gui(Times_New_Roman 13px white !fuchsia)]
fn main() {
let user = "Ada";
let score = 42.195;
println("Hi {user:?}, score={score:.2}");
println("Vector json: { [1,2,3] :j }");
}§Specifiers inside { ... }
{:?}→ Debug{:j}→ Pretty JSON (HTML-safe, monospace block){:c}→ Compact debug (stringified){:...}→ Any standardformat!spec (e.g.,:.2,:>6, …)
§Integration
#[gui]wraps your function: initializes theme, starts io::gui, runs your code.- Calls to
print/printlnare rewritten into optimizedformat!pipelines.
§Performance
- Fast scanning with
memchr/memmem, minimized allocations - Pre-sized buffers and compact tokenization
See webrust::io::gui for the runtime (HTTP API, validation, shutdown).