feat: add rust docs (#815)

* feat: add rust docs

* Import std types for built_in_hash doc
This commit is contained in:
易春风
2023-10-01 19:25:03 +08:00
committed by GitHub
parent e8bf5879b0
commit cbe76b58a2
8 changed files with 162 additions and 12 deletions

View File

@@ -532,7 +532,27 @@
=== "Rust"
```rust title=""
/* 回溯算法框架 */
fn backtrack(state: &mut State, choices: &Vec<Choice>, res: &mut Vec<State>) {
// 判断是否为解
if is_solution(state) {
// 记录解
record_solution(state, res);
// 停止继续搜索
return;
}
// 遍历所有选择
for choice in choices {
// 剪枝:判断选择是否合法
if is_valid(state, choice) {
// 尝试:做出选择,更新状态
make_choice(state, choice);
backtrack(state, choices, res);
// 回退:撤销选择,恢复到之前的状态
undo_choice(state, choice);
}
}
}
```
=== "C"