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