| Crates.io | heuristics |
| lib.rs | heuristics |
| version | 0.1.0 |
| created_at | 2025-11-17 11:09:02.674733+00 |
| updated_at | 2025-11-17 11:09:02.674733+00 |
| description | Rules of thumb to improve Rust code. |
| homepage | https://github.com/cryptopatrick/heuristics |
| repository | https://github.com/cryptopatrick/heuristics |
| max_upload_size | |
| id | 1936617 |
| size | 64,351 |
Author's bio: ๐๐ Hi, I'm CryptoPatrick! I'm currently enrolled as an
Undergraduate student in Mathematics, at Chalmers & the University of Gothenburg, Sweden.
If you have any questions or need more info, then please join my Discord Channel: AiMath
What is heuristics โข Features โข How To Use โข Documentation โข License
heuristics is a comprehensive Rust library that provides a searchable collection of computer science and Rust development heuristics. It helps developers make informed decisions about data structures, algorithms, and architectural patterns by providing curated rules of thumb with concrete recommendations.
The library enables quick discovery of the right tool for the job, whether you need O(1) lookups, persistent storage, concurrent data structures, or specialized algorithms.
heuristics provides a fast, searchable database of development heuristics with rich metadata and multiple access patterns.
Add heuristics to your Cargo.toml:
[dependencies]
heuristics = "0.1"
Or install with cargo:
cargo add heuristics
use heuristics::load_heuristics;
fn main() {
// Load the heuristics database
let db = load_heuristics();
// Search for heuristics
let results = db.search(&["hashmap", "performance"]);
for heuristic in results.iter().take(5) {
println!("{}", heuristic.title);
println!("Action: {}", heuristic.action);
if !heuristic.crates.is_empty() {
println!("Recommended crates: {}", heuristic.crates.join(", "));
}
}
// Browse by category
let categories = db.categories();
println!("Available categories: {:?}", categories);
// Get heuristics in a specific category
let concurrent = db.by_category("Concurrency & Lock-Free Heuristics");
for heuristic in concurrent {
println!("โข {}", heuristic.title);
}
// Get all heuristics
println!("Total heuristics: {}", db.all().len());
}
use heuristics::*;
fn main() {
let db = load_heuristics();
// Search with multiple keywords for better ranking
let results = db.search(&["concurrent", "lock-free", "atomic"]);
for (i, h) in results.iter().enumerate() {
println!("\n{}. {}", i + 1, h.title);
println!(" Category: {}", h.category);
println!(" Action: {}", h.action);
// Show related crates
if !h.crates.is_empty() {
println!(" Crates:");
for crate_name in &h.crates {
println!(" - {}", crate_name);
}
}
// Show standard library types
if !h.std_types.is_empty() {
println!(" Std types: {}", h.std_types.join(", "));
}
// Access full markdown content
// println!("\n{}", h.content);
}
// Find heuristics for a specific technology
let results = db.search(&["sled"]);
if !results.is_empty() {
println!("\nHeuristics mentioning 'sled':");
for h in results {
println!(" โข {} ({})", h.title, h.category);
}
}
}
The crate also includes a CLI tool:
# Install the binary
cargo install heuristics
# Search for heuristics
heuristics search hashmap lookup
# List all categories
heuristics categories
# Get heuristics in a category
heuristics category "General-Purpose Performance Heuristics"
The test suite includes comprehensive coverage of search, categorization, and data structure functionality.
# Run all tests
cargo test
# Run library tests only
cargo test --lib
# Run integration tests
cargo test --test tests
# Run with output
cargo test -- --nocapture
Test coverage includes:
Comprehensive documentation is available at docs.rs/heuristics, including:
Keybase Verification: https://keybase.io/cryptopatrick/sigs/8epNh5h2FtIX1UNNmf8YQ-k33M8J-Md4LnAN
Leave a โญ if you think this project is cool.
This project is licensed under MIT. See LICENSE for details.