Your essential collection of Rust utilities for strings, math, time, types, collections, and more.
Every craftsperson needs a well-organized toolchest. This crate provides a focused set of utilities that cover common tasks across domains without pulling in heavy dependencies.
use toolchest::prelude::*;
use std::time::Duration;
// String manipulation
let snake = strings::to_snake_case("HelloWorld"); // "hello_world"
// Math utilities
let rounded = math::round(3.14159, 2); // 3.14
let clamped = math::clamp(15, 0, 10); // 10
// Deep operations (example)
// let merged = deep::merge(&default_config, &user_config);
// Function combinators (example)
// let search = functions::debounce(expensive_search, Duration::from_millis(300));
// Type utilities
let is_empty = types::is_empty::<Vec<i32>>(&vec![]);Add to your Cargo.toml:
[dependencies]
toolchest = "0.1.0"MSRV: 1.81.0
Optional features:
json– serde/serde_json helpersfs– filesystem utilities (walkdir)
For full API details, see the docs: https://docs.rs/toolchest
- case conversion/manipulation/escape/words/slug/validators and more
- rounding/stats/ranges/numeric helpers/primes/vectors/distances
- clone/merge/equal/path and JSON path (feature:
json)
- debounce/throttle/memoize/retry/backoff/compose/rate-limiters/timeout
- checking/conversions/non-empty and helpers
- chunk/uniq/set ops/grouping/windows/cartesian/transpose/sort/find
- humanize/parse/stopwatch/backoff/cron-lite
- ranges/choices/uuid/bytes
- djb2/fnv1a/murmur3/consistent hash
- read/write/dirs/find files
- Luhn, ASCII/UTF-8, IBAN, E.164 phone, US SSN
- hex, rot13/caesar
- Zero runtime dependencies by default (feature-gated extras)
- Zero-cost abstractions
- Optimized for common cases
- Partial
no_stdsupport
| Crate | What it is | Overlap with toolchest |
When to choose it |
|---|---|---|---|
itertools |
Iterator adaptors and utilities | Some collection helpers overlap conceptually (chunking, grouping, cartesian, windows) | You need advanced iterator combinators and zero-allocation streaming transforms |
heck |
String case conversions | Overlaps with strings::case |
You only need case conversion and prefer a focused crate |
convert_case |
String case conversions | Overlaps with strings::case |
Same as above; pick one of these if you only need this |
rand |
RNGs and distributions | random provides quick, non-crypto helpers only |
You need configurable RNGs, distributions, or crypto-secure randomness |
time / chrono |
Date/time types and parsing | time module has humanize/parse/stopwatch/backoff; not a full datetime stack |
You need full-featured datetime, time zones, formatting/parsing |
regex |
Regular expressions | Minimal overlap; strings/validation provide common checks |
You need general-purpose pattern matching |
statrs |
Statistics and distributions | math has common rounding/stats helpers |
You need rich statistical distributions and tests |
serde/serde_json |
Serialization and JSON | Optional json feature provides helpers around them |
You are doing full serialization/deserialization work |
- If you only need advanced iterator adaptors, use
itertools. - If you need cryptographically secure randomness, distributions, or a configurable RNG, use
rand(and friends likerand_chacha). - If you need full datetime handling (time zones, formatting, parsing), use
timeorchrono. - If you need regex-powered text processing, use
regex. - If you only need string case conversion, use
heckorconvert_case. - If you need heavy statistics and probability distributions, use
statrs.
toolchest aims to cover a broad set of day-to-day utilities with:
- Small, focused APIs you can use in minutes
- Zero default runtime dependencies and feature-gated extras
- Pragmatic, non-crypto defaults where appropriate
It complements the crates above; use them when you need depth, use toolchest when you want breadth without pulling in many dependencies.
Replacing multiple utility crates with toolchest:
# Before
[dependencies]
convert_case = "0.6"
heck = "0.4"
stringcase = "0.2"
# After
[dependencies]
toolchest = "0.1.0"See CONTRIBUTING.md for guidelines.
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.