Skip to content

pantoken / platforms/rust/src / toRust

פונקציה: toRust()

toRust(tokens, options?): string

ניסיוני

להפיק קבועי Rust עבור ייצוג ביניים (IR) של טוקנים מפורש.

פרמטרים

tokens

לקריאה בלבד Token[]

ה-IR.

options?

RustOptions = {}

RustOptions.

מחזיר

string

קוד המקור של Rust (מודול של pub consts).

דוגמאות

egui (Color32), הפורמט המוגדר כברירת מחדל

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), מצב כהה

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