Skip to content

pantoken / platforms/rust/src / toRust

Funció: toRust()

toRust(tokens, options?): string

Experimental

Emetre constants de Rust per a un IR de token explícit.

Paràmetres

tokens

només de lectura Token[]

La IR.

options?

RustOptions = {}

RustOptions.

Retorna

string

La font de Rust (un mòdul de pub consts).

Exemples

egui (Color32), el format per defecte

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), mode fosc

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