我正在尝试使用 RustCrypto 来实例化河豚对象。该new
方法由block-cipher-trait crate 中的 traitBlockCipherVarKey
实现。
这是我的最小示例:
extern crate block_cipher_trait;
use block_cipher_trait::BlockCipherVarKey;
extern crate blowfish;
use blowfish::Blowfish;
fn main() {
let key = Vec::new();
Blowfish::new(key)
}
具有以下内容Cargo.toml
:
[dependencies]
blowfish = "0.2.1"
block-cipher-trait = "0.3.0"
我尝试构建它,但出现以下错误:
error: no associated item named `new` found for type `blowfish::Blowfish` in the current scope
--> src/main.rs:9:5
|
9 | Blowfish::new(key)
| ^^^^^^^^^^^^^
|
= note: the method `new` exists but the following trait bounds were not satisfied: `blowfish::Blowfish : block_cipher_trait::BlockCipherFixKey`, `&blowfish::Blowfish : block_cipher_trait::BlockCipherFixKey`, `&mut blowfish::Blowfish : block_cipher_trait::BlockCipherFixKey`
= help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
= help: candidate #1: `use block_cipher_trait::BlockCipherVarKey;`
为什么use block_cipher_trait::BlockCipherVarKey
不考虑在线2?为什么编译器建议我添加它,尽管它已经在这里了?