2个版本
0.1.1 | 2024年7月6日 |
---|---|
0.1.0 | 2024年7月6日 |
#2246 in 数据结构
每月223次下载
6KB
107 行
seen_set
不存储值,只存储哈希的HashSet。
当您只需要知道之前是否看到过某个值,而不想为了性能原因克隆值时,这很有用。
let mut seen = SeenSet::new();
for path in some_func_that_may_return_duplicate_paths() {
if !seen.insert(&path) {
continue;
}
// we haven't seen this path before
}
注意:对于数字等值,这将较慢。请使用常规HashSet。
依赖项
~2MB
~25K SLoC