Skip to content

pantoken-root / platforms/rust/src / toRust

Função: toRust() ​

toRust(tokens, options?): string

Experimental

Emitir constantes Rust para uma IR de tokens explícita.

Parâmetros ​

tokens ​

somente leitura Token[]

A IR.

options? ​

RustOptions = {}

RustOptions.

Retorna ​

string

O código-fonte Rust (um módulo de pub consts).

Exemplos ​

egui (Color32), o formato padrão

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), modo escuro

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