Skip to content

pantoken-root / platforms/rust/src / toRust

ฟังก์ชัน: toRust() ​

toRust(tokens, options?): string

ทดลอง

ส่งออกค่าคงที่ Rust สำหรับ IR ของโทเค็นที่ระบุอย่างชัดเจน

พารามิเตอร์ ​

tokens ​

อ่านอย่างเดียว Token[]

IR.

options? ​

RustOptions = {}

RustOptions.

คืนค่า ​

string

ซอร์สโค้ด Rust (โมดูลของ pub consts)

ตัวอย่าง ​

egui (Color32), รูปแบบเริ่มต้น

ts
import { toRust } from "@pantoken/rust";
import { byTheme } from "@pantoken/tokens";

const source = toRust(byTheme("rebrand"));
// "use egui::Color32;\npub fn 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: … };"