如何编辑Cargo.toml以便在我的Cargo包中包含资源文件?

时间:2015-03-24 10:17:13

标签: rust rust-cargo

我想用纯文本格式将单词列表与我的Cargo包捆绑在一起。我可以编辑Cargo.toml来执行此操作吗?

如果我使用了npm,我会将其添加到我的package.json:

"files": ["data/my_dictionary.txt"]

我尝试include,但它似乎无法运作。

这是我的Cargo.toml

[package]

name = "chamkho"
version = "0.0.2"
authors = ["Vee Satayamas <vsatayamas@gmail.com>"]
test = true
description = "Thai word segmentation/breaking library and command line"
documentation = "https://github.com/veer66/chamkho/blob/master/README.md"
homepage = "https://github.com/veer66/chamkho/"
repository = "https://github.com/veer66/chamkho.git"
readme = "README.md"
keywords = ["text", "nlp", "thai", "library"]
license = "BSD-2-Clause"
include = ["**/*.txt", "**/*.rs","Cargo.toml"]

[[bin]]
name = "wordcut"
path = "src/cli.rs"

这是cargo package -l

的输出
Cargo.toml
src/acc.rs
src/cli.rs
src/dict.rs
src/edge.rs
src/graph.rs
src/graph_builder.rs
src/lib.rs
src/space_acc.rs
src/wordcut.rs
tests/wordcut.rs

1 个答案:

答案 0 :(得分:7)

我相信include = ["data/my_dictionary.txt"]应该有用。

(我opened a PR将此添加到文档中。)