type-lib 1.0.0

Validation and type constraint library. Declare domain types with invariants enforced at construction. Parse-dont-validate pattern as a first-class citizen. Zero-overhead wrappers with derive macros.
Documentation
[package]
name = "type-lib"
version = "1.0.0"
edition = "2021"
rust-version = "1.75"
readme = "README.md"
license = "Apache-2.0 OR MIT"

authors = [
    "James Gober <me@jamesgober.com>"
]

description = "Validation and type constraint library. Declare domain types with invariants enforced at construction. Parse-dont-validate pattern as a first-class citizen. Zero-overhead wrappers with derive macros."

keywords = [
    "types",
    "validation",
    "newtype",
    "parse",
    "rust"
]

categories = [
    "data-structures",
    "rust-patterns"
]

documentation = "https://docs.rs/type-lib"
repository    = "https://github.com/jamesgober/type-lib"
homepage      = "https://github.com/jamesgober/type-lib"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[workspace]
members = ["derive"]
resolver = "2"

[lib]
name = "type_lib"
path = "src/lib.rs"

[features]
default = ["std"]
# `std` pulls in `alloc` and adds the `std::error::Error` impl for `ValidationError`.
std = ["alloc"]
# `alloc` enables the length rules for owned `String`/`Vec<T>` values. The core
# `Validator`/`Refined` API and all borrowed-value rules work without it.
alloc = []
# `derive` enables the `#[derive(Validated)]` macro for validated newtypes.
derive = ["dep:type-lib-derive"]

[dependencies]
type-lib-derive = { version = "1.0.0", path = "derive", optional = true }

[dev-dependencies]
# Property-based tests for rule and combinator invariants.
proptest = "1"
# Microbenchmarks for the validation hot path. Default features are disabled to
# keep the dev-dependency tree (and MSRV surface) small.
criterion = { version = "0.5", default-features = false, features = ["cargo_bench_support"] }

# The committed `Cargo.lock` pins this dev-dependency tree to versions that still
# build on the MSRV (Rust 1.75): proptest 1.4, criterion's clap 4.5, tempfile 3.14,
# and half 2.4. Newer releases of these require a newer compiler. These are
# dev-only and never reach published consumers; re-pin with `cargo update -p <crate>
# --precise <ver>` if you bump the MSRV.

[[bench]]
name = "validation"
harness = false

# The examples print output and use owned `String` values, so they require `std`.
# Declaring this keeps `--no-default-features` builds from trying to compile them.
[[example]]
name = "quick_start"
required-features = ["std"]

[[example]]
name = "built_in_rules"
required-features = ["std"]

[[example]]
name = "composing_rules"
required-features = ["std"]

[[example]]
name = "custom_rule"
required-features = ["std"]

[[example]]
name = "derive_newtype"
required-features = ["std", "derive"]

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
strip = "symbols"

[profile.bench]
opt-level = 3
lto = "fat"
codegen-units = 1
debug = true