Skip to content

pantoken / platforms/rust/src / toRust

Függvény: toRust()

toRust(tokens, options?): string

Kísérleti

Rust konstansok kibocsátása egy explicit token IR-hoz.

Paraméterek

tokens

readonly Token[]

Az IR.

options?

RustOptions = {}

RustOptions.

Visszatérés

string

A Rust forrás (egy pub consts modul).

Példák

egui (Color32), az alapértelmezett formátum

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), sötét mód

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