Skip to content

pantoken / platforms/rust/src / toRust

Funktion: toRust()

toRust(tokens, options?): string

Experimentell

Gibt Rust-Konstanten für ein explizites Token-IR aus.

Parameter

tokens

readonly Token[]

Die IR.

options?

RustOptions = {}

RustOptions.

Rückgabe

string

Der Rust-Quellcode (ein Modul von pub consts).

Beispiele

egui (Color32), das Standardformat

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), Dunkelmodus

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