我收到此错误:
error: failed to parse manifest at `...\Cargo.toml`
Caused by:
Feature `client` depends on `rusttls` which is not an optional dependency.
Consider adding `optional = true` to the dependency
如果我添加optional = true
,它就消失了,但是出于安全原因,我不希望rusttls是可选的。
此错误的确切原因是什么,除了使其可选之外,可能的解决方法是什么?
我的Cargo.toml有这个:
[features]
default = ["client", "server"]
client = ["serde_json", "serde-xml-rs", "serde_ignored", "hyper", "hyper-tls", "rusttls", "tokio-core", "url", "uuid", "multipart"]
server = ["serde_json", "serde-xml-rs", "serde_ignored", "hyper", "hyper-tls", "rusttls", "tokio-core", "tokio-proto", "tokio-tls", "regex", "percent-encoding", "url", "uuid", "multipart"]
根据我在Rust本书中所读的内容,这样做应该意味着默认情况下,客户端和服务器具有这些依赖关系,对吧?
答案 0 :(得分:2)
如果依赖项是可选的,则仅应在功能列表中包括依赖项。如果依赖项不是可选的,则仅将其包括在[dependencies]
部分中。