Skip to content

pantoken / platforms/rust/src / toRust

Funzione: toRust()

toRust(tokens, options?): string

Sperimentale

Emettere costanti Rust per un IR di token esplicito.

Parametri

tokens

readonly Token[]

L'IR.

options?

RustOptions = {}

RustOptions.

Restituisce

string

Il codice sorgente Rust (un modulo di pub consts).

Esempi

egui (Color32), il formato predefinito

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), modalità scura

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