如何在 Rust 可执行文件中嵌入资源? [英] How to embed resources in Rust executable?
本文介绍了如何在 Rust 可执行文件中嵌入资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是这个问题的表亲对 C 提出同样的要求.
This is the cousin of this question over here asking the same thing for C.
基本上,有没有比将它变成一个巨大的字节数组并将其放入源文件更好的方法?
Basically, is there a better way than to just turn it into a giant byte array and putting it in a source file?
或者,宏是否有能力做到这一点?(Rust 宏...看起来很密集,我不知道它们的确切功能.)
Alternatively, does a macro have the ability to do this? (Rust Macros... are a dense looking and their exact capabilities are not known to me.)
推荐答案
你可能想要 include_bytes!
.
You probably want include_bytes!
.
如果您使用的是旧版本的 Rust,请使用 include_bin!
代替.
If you are in older versions of Rust, use include_bin!
instead.
这篇关于如何在 Rust 可执行文件中嵌入资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文