Skip to content

pantoken / platforms/rust/src / toRust

Functie: toRust()

toRust(tokens, options?): string

Experimenteel

Genereer Rust-constanten voor een expliciete token-IR.

Parameters

tokens

alleen-lezen Token[]

De IR.

options?

RustOptions = {}

RustOptions.

Retourneert

string

De Rust-bron (een module van pub consts).

Voorbeelden

egui (Color32), het standaardformaat

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), donkere modus

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