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

Vee*_*mas 5 rust rust-cargo

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

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

"files": ["data/my_dictionary.txt"]
Run Code Online (Sandbox Code Playgroud)

我试过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"
Run Code Online (Sandbox Code Playgroud)

这是输出 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
Run Code Online (Sandbox Code Playgroud)

huo*_*uon 7

我认为include = ["data/my_dictionary.txt"]应该工作.

(我打开了一个PR,将其添加到文档中.)