# 错误[E0599]：在当前作用域中，结构体 `std::collections::HashMap<String, i32>` 上没有找到名为 `iter` 的方法

- **ID:** `rust/e0599-no-method-named-iter-found`
- **领域:** rust
- **类别:** type_error
- **错误码:** `E0599`
- **验证级别:** ai_generated
- **修复率:** 93%

## 根因

HashMap 没有返回元素迭代器的 `iter` 方法；应对引用使用 `iter()` 或对所有权使用 `into_iter()`。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| rustc 1.58.0 | active | — | — |
| rustc 1.64.0 | active | — | — |
| rustc 1.71.0 | active | — | — |

## 解决方案

1. ```
   对引用使用 `map.iter()`：`for (key, value) in &map { ... }` 或 `let iter = map.iter();`
   ```
2. ```
   对所有权使用 `into_iter()`：`for (key, value) in map { ... }`
   ```
3. ```
   使用 `values()` 或 `keys()` 方法：`for value in map.values() { ... }`
   ```

## 无效尝试

- **** — Iterator is automatically in scope. The issue is that HashMap doesn't have a method named `iter` without the trait bounds being satisfied. (90% 失败率)
- **** — The method exists but is named `into_iter()` for owned HashMap. `iter()` exists on references like `&map`. (70% 失败率)
- **** — Iterator is a trait, not a derive macro. You cannot derive Iterator for HashMap. (95% 失败率)
