Types &引用;使用未声明的类型名称;使用泛型类型时

Types &引用;使用未声明的类型名称;使用泛型类型时,types,rust,Types,Rust,我正在用Rust编写并发字典的基本结构,首先简单地将现有的HashMap包装在Arc::new(Mutex::new(hash\u map\u占位符))中。然而,几乎我一开始,事情就开始出错。我在将值向下传递到普通HashMap时遇到了问题,因此我甚至无法开始使用包装版本。我当前遇到以下错误: concurrent_dictionary.rs:11:39: 11:40 error: use of undeclared type name `K` concurrent_dictionary.rs:

我正在用Rust编写并发字典的基本结构,首先简单地将现有的HashMap包装在
Arc::new(Mutex::new(hash\u map\u占位符))
中。然而,几乎我一开始,事情就开始出错。我在将
值向下传递到普通HashMap时遇到了问题,因此我甚至无法开始使用包装版本。我当前遇到以下错误:

concurrent_dictionary.rs:11:39: 11:40 error: use of undeclared type name `K`
concurrent_dictionary.rs:11 impl Default for ConcurrentDictionary<K, V> {
                                                              ^
concurrent_dictionary.rs:11:42: 11:43 error: use of undeclared type name `V`
concurrent_dictionary.rs:11 impl Default for ConcurrentDictionary<K, V> {

您需要声明您使用的任何泛型类型:

impl<K, V> Default for ConcurrentDictionary<K, V> {

您需要对调用函数应用相同的限制。

太好了,谢谢!我只是想把语法弄对。现在我遇到了一个文档测试错误,但我很有希望自己能解决这个问题。@NuclearChemist如果您遇到任何问题,请随时回来搜索/问另一个问题!
impl<K, V> Default for ConcurrentDictionary<K, V> {
impl<K, V> Default for ConcurrentDictionary<K, V>
    where K: std::cmp::Eq + std::hash::Hash