Files
gists/archive/experimental/rust/uniq2.rs
T
tobias 1cbf8afb4a chore: cleanup — untrack binaries, consolidate Go dirs, dedupe tools
- Untrack and delete compiled binaries (tarsum, gosoft.exe, rust uniq/uniq2);
  ignore build outputs (dist/, bin/, *.exe, *.test, .ruff_cache/)
- Merge tools/go/ and projects/go-tools/go/ into projects/go-tools/<name>/
- Fix goipgrep .gitignore: bare 'ipgrep' pattern was ignoring cmd/ipgrep/,
  so the main entrypoint was never tracked; now anchored to /ipgrep
- Archive duplicate implementations to archive/experimental/{rust,go}/
  (uniq, between, tarsum rewrites); canonical versions stay in tools/
- Update README tool catalog to match new layout

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 13:42:45 +02:00

37 lines
927 B
Rust

use std::collections::HashSet;
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
struct HashOnlySet {
set: HashSet<u64>,
}
impl HashOnlySet {
fn new() -> HashOnlySet {
HashOnlySet { set: HashSet::new() }
}
fn insert<T: Hash>(&mut self, item: &T) -> bool {
let hash = Self::hash_item(item);
self.set.insert(hash)
}
fn contains<T: Hash>(&self, item: &T) -> bool {
let hash = Self::hash_item(item);
self.set.contains(&hash)
}
fn hash_item<T: Hash>(item: &T) -> u64 {
let mut hasher = DefaultHasher::new();
item.hash(&mut hasher);
hasher.finish()
}
}
fn main() {
let mut set = HashOnlySet::new();
set.insert(&"Hello, world!");
println!("Contains 'Hello, world!': {}", set.contains(&"Hello, world!"));
println!("Contains 'Goodbye, world!': {}", set.contains(&"Goodbye, world!"));
}