Restructure repository: organize tools by purpose, create what search tool
- Move single-file tools to tools/ organized by category (security, forensics, data, etc.) - Move multi-file projects to projects/ (go-tools, puzzlebox, timesketch, rust-tools) - Move system scripts to scripts/ (proxy, display, setup, windows) - Organize config files in config/ (shell, visidata, applications) - Move experimental tools to archive/experimental - Create 'what' fuzzy search tool with progressive enhancement (ollama->fzf->grep) - Add initial metadata database for intelligent tool discovery - Preserve git history using 'git mv' commands
This commit is contained in:
36
projects/rust-tools/uniq2.rs
Normal file
36
projects/rust-tools/uniq2.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
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!"));
|
||||
}
|
||||
Reference in New Issue
Block a user