# type-lib v1.0.0 — Stable
**1.0 is here.** The public API is frozen under SemVer: parse-dont-validate domain
types built from a small, composable core, with zero runtime overhead. There are
no code changes from `0.9.0` — this release is the stability commitment, the final
benchmark numbers, and the documentation that says so.
## What is type-lib?
A validation and type-constraint library for Rust. You declare domain types whose
invariants are enforced **once**, at construction, and proven by the type system
thereafter — so code that receives a validated value never re-checks it. Wrappers
are zero-overhead, the core is `no_std`-friendly, and rules are reusable and
composable.
```rust
use type_lib::combinator::And;
use type_lib::rules::{LenRange, Trimmed};
use type_lib::Refined;
type Username = Refined<String, And<Trimmed, LenRange<3, 16>>>;
let user = Username::new("alice".to_owned());
assert!(user.is_ok());
assert!(Username::new(" x ".to_owned()).is_err());
```
With the `derive` feature, the same rule backs a named domain type:
```rust
use type_lib::combinator::And;
use type_lib::rules::{LenRange, Trimmed};
use type_lib::Validated;
#[derive(Validated)]
#[valid(And<Trimmed, LenRange<3, 16>>)]
pub struct Username(String);
```
## The 1.0 surface
- **Foundation** — [`Validator`] (a type-level rule), [`Refined<T, V>`] (a
`#[repr(transparent)]` wrapper proven to satisfy `V`), and [`ValidationError`]
(a `Copy`, allocation-free error).
- **Built-in rules** — length (`NonEmpty`, `MinLen`, `MaxLen`, `LenRange` over the
`HasLength` trait), numeric (`Positive`, `NonNegative`, `Negative`,
`NonPositive`, `InRange`), and string (`Ascii`, `Alphanumeric`, `Trimmed`).
- **Combinators** — `And`, `Or`, `Not`, composing rules at the type level.
- **Derive** — `#[derive(Validated)]` with `#[valid(<Validator>)]`, behind the
`derive` feature.
- **`prelude`** and the `VERSION` constant.
## Stability promise
`v1.0.0` is covered by [Semantic Versioning](https://semver.org/):
- No breaking change ships without a `2.0`.
- New rules, combinators, and trait impls arrive as additive `1.x` minor releases.
- Bug fixes are patch releases.
- The error **codes** returned by the built-in rules (`"non_empty"`, `"max_len"`,
`"in_range"`, `"trimmed"`, `"not"`, …) are stable across `1.x`; only
human-readable messages may be reworded.
- [`Validator`] and `HasLength` are intentionally open (not sealed) — implementing
them for your own rules and containers is a supported, stable extension point.
MSRV is **Rust 1.75**, and a change to it will be treated as a minor-version bump.
## Performance
Validation is the only runtime cost; the wrapper adds none. Final Criterion means
(Windows x86_64, Rust stable 1.95, `cargo bench --bench validation`):
| `Refined::new` — `Ascii` on a short `&str` | ~1.01 ns |
| `Refined::new` — `LenRange<3, 16>` on a `&str` | ~2.39 ns |
| `Refined::new` — `InRange<0, 100>` on an `i32` | ~2.58 ns |
| `Refined::get` | ~0.23 ns |
| `Refined` `Deref` | ~0.23 ns |
The accessors compile down to a field read; `Refined<T, V>` is the same size as
`T`.
## Breaking changes
**None.** `v1.0.0` is identical in behaviour and API to `v0.9.0`.
## Verification
Run on Windows x86_64 (Rust stable 1.95 and MSRV 1.75.0) and on Linux (WSL2
Ubuntu); identical commands pass via the CI matrix (Linux/macOS/Windows ×
{stable, 1.75.0}):
```bash
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo clippy --no-default-features --lib --tests -- -D warnings
cargo test --workspace --all-features
cargo test --no-default-features
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --all-features
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --no-default-features
cargo bench --bench validation
```
All green. Counts at this tag:
- `--all-features`: 26 unit + 4 derive + 6 other integration + 8 property + 38 doctests.
- `--no-default-features`: 26 unit + 6 integration + 8 property + 37 doctests.
The published `type-lib` crate has no runtime dependencies by default; the
`derive` feature adds `syn` / `quote` / `proc-macro2` at build time.
## Installation
```toml
[dependencies]
type-lib = "1.0.0"
# with the derive macro
type-lib = { version = "1.0.0", features = ["derive"] }
# no_std (core API + borrowed-value rules)
type-lib = { version = "1.0.0", default-features = false }
```
MSRV: Rust 1.75.
## Documentation
- [README](https://github.com/jamesgober/type-lib/blob/main/README.md)
- [API Reference](https://github.com/jamesgober/type-lib/blob/main/docs/API.md)
- [CHANGELOG](https://github.com/jamesgober/type-lib/blob/main/CHANGELOG.md)
## Thanks
To everyone who kicked the tyres through the `0.x` series. Onward to `1.x`.
---
**Full diff:** [`v0.9.0...v1.0.0`](https://github.com/jamesgober/type-lib/compare/v0.9.0...v1.0.0).
**Changelog:** [`CHANGELOG.md`](https://github.com/jamesgober/type-lib/blob/main/CHANGELOG.md#100---2026-05-27).