Skip to content

pantoken / platforms/rust/src / toRust

Fall: toRust()

toRust(tokens, options?): string

Tilrauna

Búa til Rust-fasta fyrir skýrt token-IR.

Færibreytur

tokens

readonly Token[]

IR-ið.

options?

RustOptions = {}

RustOptions.

Skilar

string

Rust-kóði (módúll af pub consts).

Dæmi

egui (Color32), sjálfgefið snið

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), dökkt þema

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