Pre-1.0 (
0.x). While the crate is at version 0, how the helpers are split into modules — and therefore into Cargo features — may change between releases, and the code-quality and security checks will keep improving. Do not use it in production for critical or sensitive applications until 1.0, which waits for independent security audits. Pin the exact version and read the changelog before upgrading.
Overview
helpers4 is a collection of small, typed helpers for the everyday code every project ends up
rewriting: string casing, slice operations, expiring caches, hex, network checks, and more. Each
helper does one thing, returns a typed error instead of panicking, and ships with tests and a
runnable example.
Modules
One module per category, each behind a Cargo feature of the same name (all enabled by default):
| Module | What it covers |
|---|---|
string |
case conversion, slugs, truncation, indentation, whitespace, HTML escaping |
array |
unique, difference, intersection, grouping, counting, duplicates, interleaving |
number |
interpolation, rounding, mean, median, percentages, gcd and lcm |
cache |
maps and sets whose entries expire, with the clock passed in |
env |
reading and editing .env files as text |
hex |
hexadecimal encoding and decoding with typed errors |
net |
is this IP address public (an SSRF guard), is this a valid hostname |
http |
extracting a bearer token from an Authorization header |
time |
the system clock as unix time, without a silent 0 |
More are planned (random values and identifiers, validation, iterators, maps and sets, durations, …): see the roadmap.
Quick start
use hex;
use is_public_ip;
use slugify;
assert_eq!;
assert_eq!;
assert!; // the cloud metadata address
Names can repeat across modules, so always go through the module path
(helpers4::string::capitalize) and never glob-import a module.
Key features
- Zero dependencies by default: a module that needs one gets its own optional feature
- Take only what you use: one Cargo feature per module, so unused modules are not compiled
- Typed errors instead of panics:
unsafeis forbidden, andunwrap,expectandpanic!are denied outside tests - Explicit inputs: the clock and the process environment are parameters, never ambient
- Standard library first: nothing here duplicates what
stdalready offers - Fully tested: 100% coverage of lines, functions and regions, unit tests, property-based tests, doc tests, mutation testing and benchmarks, all enforced or tracked in CI
- AI-ready:
llms.txtdescribes every module, and every example is a doc test
Documentation
Every helper, with its signature, parameters, errors and examples, is on helpers4.dev/rust and on docs.rs.
Development
See AGENTS.md for the layout and rules, and CONTRIBUTING.md for how to add a helper or a module.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md and the organization's Contributing Guide.
- Fork the repository
- Create a feature branch (
git checkout -b feat/amazing-feature) - Commit your changes following Conventional Commits
- Push to the branch and open a Pull Request
To report a vulnerability, see SECURITY.md.
License
Licensed under the GNU Lesser General Public License v3.0 or later: you can freely use it in proprietary or open-source projects.