gpt4 book ai didi

rust - 使用本地目录中的依赖项时,特征未实现错误

转载 作者:行者123 更新时间:2023-12-03 11:42:59 25 4
gpt4 key购买 nike

使用此cargo.toml,代码可以正常工作:

[dependencies]
bellman = "0.6.0"
rand = "0.7"
pairing = {version = "0.16"}
sha2 = {version = "0.9.1"}
但是,如果我下载“pairing”并通过这种方式更新cargo.toml中的路径,则:
[dependencies]
bellman = "0.6.0"
rand = "0.7"
pairing = {version = "0.16", path = "../pairing"}
sha2 = {version = "0.9.1"}
我得到并指出错误,指出未实现某些特征。我究竟做错了什么?
首先下载“配对”的原因是我想在那里修改一些代码。
配对箱的github链接: https://github.com/zkcrypto/pairing.git
错误信息:
error[E0277]: the trait bound `E: ff::ScalarEngine` is not satisfied
--> src\main.rs:21:27
|
21 | fn sha256t<E: Engine, CS: ConstraintSystem<E>>(
| ^^^^^^^^^^^^^^^^^^^ the trait `ff::ScalarEngine` is not implemented for `E`
|
help: consider further restricting this bound with `+ ff::ScalarEngine`
--> src\main.rs:21:15
|
21 | fn sha256t<E: Engine, CS: ConstraintSystem<E>>(
| ^^^^^^
= note: required by `bellman::ConstraintSystem`

error[E0277]: the trait bound `E: ff::ScalarEngine` is not satisfied
--> src\main.rs:55:17
|
55 | impl<E: Engine> Circuit<E> for MyCircuit {
| ^^^^^^^^^^ the trait `ff::ScalarEngine` is not implemented for `E`
|
help: consider further restricting this bound with `+ ff::ScalarEngine`
--> src\main.rs:55:9
|
55 | impl<E: Engine> Circuit<E> for MyCircuit {
| ^^^^^^

error[E0277]: the trait bound `E: ff::ScalarEngine` is not satisfied
--> src\main.rs:56:23
|
56 | fn synthesize<CS: ConstraintSystem<E>>(self, cs: &mut CS) -> Result<(), SynthesisError> {
| ^^^^^^^^^^^^^^^^^^^ the trait `ff::ScalarEngine` is not implemented for `E`
|
help: consider further restricting this bound with `+ ff::ScalarEngine`
--> src\main.rs:55:9
|
55 | impl<E: Engine> Circuit<E> for MyCircuit {
| ^^^^^^
= note: required by `bellman::ConstraintSystem`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `sha2`.

最佳答案

此处bellman取决于pairing的问题。在替换直接依赖项(即在Cargo.toml中)时,仍然从https://crates.io获取bellman的间接依赖项。您可以“修补”它:

# this will replace all of the `pairing` crates to be fetched from crates-io
[patch.crates-io]
pairing = { path = '../pairing' }
更多信息 at cargo reference。此外,您可以使用 cargo tree命令列出所有依赖项,这可能对查找这样的 crate 很有帮助。

关于rust - 使用本地目录中的依赖项时,特征未实现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62772509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com