Skip to content

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