Skip to content

pantoken / platforms/rust/src / toRust

Funkcja: toRust()

toRust(tokens, options?): string

Eksperymentalne

Wygeneruj stałe Rust dla jawnego IR tokenów.

Parametry

tokens

tylko do odczytu Token[]

Reprezentacja pośrednia (IR).

options?

RustOptions = {}

RustOptions.

Zwraca

string

Kod źródłowy Rust (moduł pub const).

Przykłady

egui (Color32), domyślny format

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), tryb ciemny

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