Skip to content

Commit

Permalink
Automatic deploy to GitHub Pages: 0c42e45
Browse files Browse the repository at this point in the history
  • Loading branch information
GHA CI committed Nov 14, 2023
1 parent 1fe83a7 commit c0a9d57
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions master/lints.json
Original file line number Diff line number Diff line change
Expand Up @@ -3532,6 +3532,21 @@
"applicability": "Unresolved"
}
},
{
"id": "iter_over_hash_type",
"id_span": {
"path": "src/iter_over_hash_type.rs",
"line": 38
},
"group": "restriction",
"level": "allow",
"docs": "\n### What it does\nThis is a restriction lint which prevents the use of hash types (i.e., `HashSet` and `HashMap`) in for loops.\n\n### Why is this bad?\nBecause hash types are unordered, when iterated through such as in a for loop, the values are returned in\nan undefined order. As a result, on redundant systems this may cause inconsistencies and anomalies.\nIn addition, the unknown order of the elements may reduce readability or introduce other undesired\nside effects.\n\n### Example\n```rust\n let my_map = std::collections::HashMap::<i32, String>::new();\n for (key, value) in my_map { /* ... */ }\n```\nUse instead:\n```rust\n let my_map = std::collections::HashMap::<i32, String>::new();\n let mut keys = my_map.keys().clone().collect::<Vec<_>>();\n keys.sort();\n for key in keys {\n let value = &my_map[key];\n }\n```",
"version": "1.75.0",
"applicability": {
"is_multi_part_suggestion": false,
"applicability": "Unresolved"
}
},
{
"id": "iter_overeager_cloned",
"id_span": {
Expand Down

0 comments on commit c0a9d57

Please sign in to comment.