Skip to content

pantoken-root / platforms/rust/src / toRust

Funksjon: toRust() ​

toRust(tokens, options?): string

Eksperimentell

Generer Rust-konstanter for en eksplisitt token IR.

Parametere ​

tokens ​

skrivbeskyttet Token[]

IR-en.

options? ​

RustOptions = {}

RustOptions.

Returnerer ​

string

Rust-kildekoden (et modul av pub consts).

Eksempler ​

egui (Color32), standardformatet

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

const source = toRust(byTheme("rebrand"));
// "use egui::Color32;\npub fn color_background_brand() -> Color32 { Color32::from_rgb(…) }"

iced (Color), mørk modus

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: … };"