# Rust 外部老程序语料（10 个）

判据：`dotnet scripts/vmlcli/bin/Release/net10.0/vmlcli.dll <文件> --lang rust --timeout 25`
—— **只看编不编得过**（能不能跑、输出对不对不在本批判据内，见本目录 `../README.md`）。
三条口径（禁汇编 / 禁硬件地址 / 禁界面库）经 `scripts/compat-external-lint.py --dir .` 机械判：
**10/10 全过**（2026-10-14）。

## 结果汇总

| # | 文件名 | 类别 | 来源 URL | 许可 | 行数 | 编译 | 第一条错误（原文） |
|:-:|:--|:--|:--|:--|:-:|:-:|:--|
| 1 | `towers_of_hanoi.rs` | 递归/控制流 | https://rosettacode.org/wiki/Towers_of_Hanoi#Rust | GFDL 1.3 | 11 | ✅ 通过 | — |
| 2 | `ackermann_function.rs` | 递归/控制流 | https://rosettacode.org/wiki/Ackermann_function#Rust | GFDL 1.3 | 14 | ✅ 通过 | — |
| 3 | `fizzbuzz.rs` | 数值/控制流 | https://rosettacode.org/wiki/FizzBuzz#Rust | GFDL 1.3 | 10 | ✅ 通过 | — |
| 4 | `selection_sort.rs` | 数组/集合 | https://rosettacode.org/wiki/Sorting_algorithms/Selection_sort#Rust | GFDL 1.3 | 29 | ✅ 通过 | — |
| 5 | `hailstone_sequence.rs` | 数值/算术 | https://rosettacode.org/wiki/Hailstone_sequence#Rust | GFDL 1.3 | 40 | ❌ 失败 | `<input>:21:35: error: 期望 RBRACKET，实际得到 RANGE` |
| 6 | `palindrome_detection.rs` | 字符串/文本 | https://rosettacode.org/wiki/Palindrome_detection#Rust | GFDL 1.3 | 25 | ❌ 失败 | `<input>:9:14: error: 期望 SEMICOLON，实际得到 IDENTIFIER` |
| 7 | `caesar_cipher.rs` | 字符串/文本 | https://rosettacode.org/wiki/Caesar_cipher#Rust | GFDL 1.3 | 36 | ❌ 失败 | `<input>:7:25: error: 意外的token: IDENTIFIER 'exit_err'` |
| 8 | `bubble_sort.rs` | 数组/集合 | https://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort#Rust | GFDL 1.3 | 33 | ❌ 失败 | `<input>:10: error: 未定义的函数 'method_swap_2'（引用 1 次）` |
| 9 | `hundred_doors.rs` | 经典小游戏/模拟 | https://rosettacode.org/wiki/100_doors#Rust | GFDL 1.3 | 17 | ❌ 失败 | `<input>:2:31: error: 期望 RBRACKET，实际得到 SEMICOLON` |
| 10 | `game_of_life.rs` | 经典小游戏/模拟 | https://rosettacode.org/wiki/Conway%27s_Game_of_Life#Rust | GFDL 1.3 | 73 | ❌ 失败 | `<input>:4:1: error: 意外的token: IDENTIFIER 'Cell'` |

**收到 10 个 / 通过 4 个 / 失败 6 个。**

## 每条失败的根因（对应源码那一行）

| 文件 | 源码行 | 语言特性 | 前端现状 |
|:--|:--|:--|:--|
| `hundred_doors.rs` | `let mut door_open = [false; 100];` | 数组重复初始化器 `[x; N]` | 只认 `[a, b, c]`；见到 `;` 就报「期望 RBRACKET」 |
| `hailstone_sequence.rs` | `test_hailseq[0..4]` | 切片 `a[x..y]` | 不支持 Range 下标（清单 §3 已记） |
| `palindrome_detection.rs` | `macro_rules! test {` | 宏定义 `macro_rules!` | 不支持宏定义 |
| `caesar_cipher.rs` | `.unwrap_or_else(|| exit_err(...))` | 闭包 `\|\|` | 不支持闭包（清单 §3 已记） |
| `game_of_life.rs` | `type Cell = (i32, i32);` | 类型别名 `type` | 不支持 `type` 别名 |
| `bubble_sort.rs` | `values.swap(i - 1, i);` | 切片方法 `.swap()` | 方法调用退化成 `method_swap_2` 函数、库里没有 ⇒ 链接期「未定义的函数」 |

## 备注

- 语料**不进仓库**（第三方源码、许可状况参差），见本目录 `.gitignore` 说明。
- 来源全部是 **Rosetta Code**（站点声明内容按 **GNU FDL 1.3**，除非该页另行注明）；每条取的是页面上
  标 `=={{header|Rust}}==` 那一节的第 1 个 `<syntaxhighlight lang="rust">` 代码块，逐字未改。
- 挑选时**避开了**用到外部 crate（`rand` / `image` / `num_complex` / `unicode_segmentation`）或
  依赖 stdin/命令行参数的版本，以保证"单文件、自包含、编译测试不被运行时缺件污染"。
