Skip to content

pantoken / platforms/rust/src / toRust

Función: toRust()

toRust(tokens, options?): string

Experimental

Emitir constantes de Rust para un IR de tokens explícito.

Parámetros

tokens

solo lectura Token[]

El IR.

options?

RustOptions = {}

RustOptions.

Devuelve

string

El código fuente de Rust (un módulo de pub consts).

Ejemplos

egui (Color32), el formato por defecto

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

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