rust - 在 Rust 中推送运行时操作以编译时间?

标签 rust runtime markdown compile-time

我可以include external source markdown into the binary with include_str!() ,

static HOME: &'static str = include_str!("../content/foo.md");

有了这个我的紫杉应用程序读取
-rw-r--r-- 1 ecarroll ecarroll 111K Jun 14 19:58 ./static/wasm_bg.wasm

现在,如果我想将该 Markdown 显示为 HTML,我可以使用 comrak 模块并调用markdown_to_html .这正是我想要的,
 use comrak;
 comrak::markdown_to_html(HOME, &comrak::ComrakOptions::default())

事件虽然 HOMEstatic str这导致 1.3M装配(从 111K 开始)
-rw-r--r-- 1 ecarroll ecarroll 1.3M Jun 14 19:59 ./static/wasm_bg.wasm

无论如何,语言中是否有将此计算插入编译时并排除所有 comrak来自运行时网络程序集的东西?

最佳答案

您可以使用 build script (build.rs) . examples page列表 "code generation"您可能可以适应。

关于rust - 在 Rust 中推送运行时操作以编译时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62379899/

相关文章:

pdf - Pandoc 禁用从 Markdown 到 PDF 转换的图形拉伸(stretch)

rust - 为什么将移动值的成员分配给时编译不会失败?

user-interface - 用冰 rust 画img

rust - "overflow evaluating the requirement"尝试延迟关联类型时

rust - 定义一个结构体,其中只能默认某些字段

latex - pandoc LaTex 添加 CSS 创建 PDF

c# - 在按下按钮时创建对象的新实例

java - 检查 Java 版本 : could not find java. dll 时出错

c# - 混合模式程序集是针对运行时版本 'v1.1.4322' 构建的,无法在 4.0 运行时中加载

css - 如何在 reveal.js 中使用两列布局?