Skip to content

pantoken / platforms/rust/src / toRust

Função: toRust()

toRust(tokens, options?): string

Experimental

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

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