Skip to content

pantoken / platforms/rust/src / toRust

Funktio: toRust()

toRust(tokens, options?): string

Kokeellinen

Luo Rust-vakiot eksplisiittiselle token-IR:lle.

Parametrit

tokens

vain-luku Token[]

IR.

options?

RustOptions = {}

RustOptions.

Palauttaa

string

Rust-lähdekoodi (moduuli pub const-ista).

Esimerkit

egui (Color32), oletusmuoto

ts
import { toRust } from "@pantoken/rust";
import { byTheme } from "@pantoken/tokens";

const source = toRust(byTheme("rebrand"));
// "use egui::Color32;\npub const COLOR_BACKGROUND_BRAND: Color32 = Color32::from_rgb(…);"

iced (Color), tumma tila

ts
import { toRust } from "@pantoken/rust";
import { byTheme } from "@pantoken/tokens";

const source = toRust(byTheme("rebrand"), { format: "iced", mode: "dark" });
// "use iced::Color;\npub const COLOR_BACKGROUND_BRAND: Color = Color { r: …, g: …, b: …, a: … };"