Skip to content

Helpers4 Rust

General-purpose Rust helpers — one crate, one module per category, zero third-party dependencies by default, exhaustively tested.

A collection of small, well-tested helpers to stop rewriting the same utility code across every project: text, slices, hexadecimal, .env files, expiring caches, network address checks, HTTP header values, the system clock. Helpers that the standard library already covers are simply not provided (chunks, partition, zip, …).

It grew out of code that kept being copied between real projects, then reviewed and hardened until it was worth publishing. See the philosophy for the reasoning.

  • One crate, one Cargo feature per module — compile only what you use
  • Zero third-party dependencies by default — nothing but std in your build
  • No unsafe — and unwrap, expect and panic! are denied outside tests; fallible helpers return typed errors you can match on
  • Battle-tested — 100% line, function and region coverage; unit, property-based and doc tests; mutation testing; benchmarks
  • Explicit inputs — the clock and the process environment are parameters, never read behind your back
  • Names may repeat across modules — always imported through the module path, see Names and imports
  • AI-ready — the whole reference is one file, and every example in the module pages is a doctest that runs in CI
cargo add helpers4

Every module is enabled by default. To compile only what you use, list the modules (each one is a Cargo feature of the same name):

cargo add helpers4 --no-default-features --features string,hex

Details, and the list of modules, in Getting Started and Modules.

use helpers4::net::is_valid_hostname;
use helpers4::string::slugify;

assert_eq!(slugify("Hello, World!"), "hello-world");
assert!(is_valid_hostname("example.com").is_ok());

The crate is pre-1.0: the API can still change between 0.0.x releases, and every change is listed in the changelog.

Found a bug or want to suggest a helper? Open an issue on the Rust repository, and read Contributing before sending code.

Want to improve this documentation? Use the Edit page link at the bottom of any page, or open an issue on the website repository. The module pages are generated from the crate’s own documentation, so a fix to a helper’s description belongs in its source.