Skip to content

pantoken-root / platforms/rust/src / toRust

関数: toRust() ​

toRust(tokens, options?): string

実験的

明示的なトークンIR用のRust定数を出力する。

パラメーター ​

tokens ​

読み取り専用 Token[]

IR(中間表現)。

options? ​

RustOptions = {}

RustOptions.

戻り値 ​

string

Rustソース(pub constのモジュール)。

例 ​

egui (Color32)、デフォルトのフォーマット

ts
import { toRust } from "@pantoken/rust";
import { byTheme } from "@pantoken/tokens";

const source = toRust(byTheme("rebrand"));
// "use egui::Color32;\npub fn 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: … };"