#struct #design #ant #generate #table #antd

app rust2antd

Generate Ant Design table from Rust struct

1 unstable release

0.1.0 Jun 30, 2024

#140 in Procedural macros

MIT license

10KB
165 lines

rust2antd

这是一个转换工具, 用于将 Rust struct 转换为 antd 的 Table ColumnsType 和 Interface 的定义

例如有一个rust struct:

#[derive(Debug, Serialize, Clone)]
pub struct MenuList {
    pub id: i32,
    pub menu_name: String,
}

转换成antd:

export interface MenuList {
    id: number;
    menu_name: string;
}

const columns: ColumnsType<MenuList> = [
    {
      title: t('id'),
      dataIndex: 'id',
    },
    {
      title: t('menu_name'),
      dataIndex: 'menu_name',
    },
  ]

使用方法

安装 rust2antd:

cargo install rust2antd

然后在 rust 项目的struct的目录下运行:

rust2antd 

或者指定输入文件:

rust2antd <input_file>

其中 <input_file> 是 rust struct 的路径, 例如 src/vo/vo.rs

Dependencies

~0.3–0.8MB
~18K SLoC