Show HN: Galois connections for composable numeric casts in Rust
A new Rust crate has been released that implements Galois connections for safe, lawful numeric type casting. The library focuses on compile-time verification and property-tested invariants to prevent common casting errors.
Why it matters
This tool improves software reliability in systems programming by providing a safer alternative to standard, potentially lossy numeric casting operators.
Galois connections as first-class Rust values. Use them to cast lawfully between numeric types, and compose ladders of conversions whose round-trip behavior is determined by simple inequalities rather than left to chance. Every operation derived from a Conn (rounding, saturation, median, ...) carries a property-tested invariant. The generated fixed-width integer, Q-format, NonZero, and iso families also have Kani harnesses for full bit-width SMT proofs; float SMT coverage is narrower and called out under Testing → SMT verification .
MSRV: Rust 1.88. Bumps to the MSRV will be treated as minor-version changes — pin connections = "0.1" and an MSRV upgrade will surface as a 0.2 release rather than a silent break on a patch update.
This crate is a Rust-native port of the Haskell library connections .
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in