ranch 0.6.0

Ranged integer types and math
Documentation
# Ranch

[![tests](https://github.com/AldaronLau/ranch/actions/workflows/ci.yml/badge.svg)](https://github.com/AldaronLau/ranch/actions/workflows/ci.yml)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/AldaronLau/ranch)](https://github.com/AldaronLau/ranch)
[![GitHub contributors](https://img.shields.io/github/contributors/AldaronLau/ranch)](https://github.com/AldaronLau/ranch/graphs/contributors)  
[![Crates.io](https://img.shields.io/crates/v/ranch)](https://crates.io/crates/ranch)
[![Crates.io](https://img.shields.io/crates/d/ranch)](https://crates.io/crates/ranch)
[![Crates.io (recent)](https://img.shields.io/crates/dr/ranch)](https://crates.io/crates/ranch)  
[![Crates.io](https://img.shields.io/crates/l/ranch)](https://github.com/search?q=repo%3AAldaronLau%2Franch+path%3A**%2FLICENSE*&type=code)
[![Docs.rs](https://docs.rs/ranch/badge.svg)](https://docs.rs/ranch/)

Ranged integer types and math for Rust

Do you ever need to restrict a `u8` from 0 to 100 or restrict any other integer
type to any other range?  Then this crate is for you!  The ranges are encoded in
the type system, so you only need to validate the range once (and it can even be
at compile time!).  This crate is sort of like a combination of similar crates
[deranged](https://docs.rs/crate/deranged) and [ux](https://docs.rs/crate/ux).

This crate heavily leverages the type system to allow for powerful ranged
integer mathematics, covering arbitrary i{N} / u{N} types, unit integers,
non-zero divisions, and const operations.  Enable the _**`serde`**_ feature for
range-validated deserialization / serialization (implements `Serialize` and
`Deserialize` for `Ranged*` types).

Check out the [documentation] for examples.

### Features

 - Compile-time and runtime checked constructors for ranged integers
 - Strict, checked, saturating, constant, and ranged operations
 - Conversions between for ranged integers
 - Aliases for arbitrary width integers, unit integers, and ASCII types
 - Optional crate support
   - Enable [**_`bytemuck`_**]https://docs.rs/crate/bytemuck for casting as
     "plain old data"
   - Enable [**_`serde`_**]https://docs.rs/crate/serde for serialization and
     deserialization
   - Enable [**_`zeroize`_**]https://docs.rs/crate/zeroize for secure secret
     clearing

## MSRV

The current MSRV is Rust 1.85.

Any future MSRV updates will follow the [Ardaku MSRV guidelines].

## License

Copyright © 2025-2026 The Ranch Contributors.

Licensed under any of
 - Apache License, Version 2.0, ([LICENSE\_APACHE] or
   <https://www.apache.org/licenses/LICENSE-2.0>)
 - Boost Software License, Version 1.0, ([LICENSE\_BOOST] or
   <https://www.boost.org/LICENSE_1_0.txt>)
 - MIT License, ([LICENSE\_MIT] or <https://mit-license.org/>)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
licensed as described above, without any additional terms or conditions.

## Help

If you want help using or contributing to this library, feel free to send me an
email at <aldaronlau@gmail.com>.

[Ardaku MSRV guidelines]: https://github.com/ardaku/.github/blob/v1/profile/MSRV.md
[LICENSE\_APACHE]: https://github.com/AldaronLau/ranch/blob/v0/LICENSE_APACHE
[LICENSE\_BOOST]: https://github.com/AldaronLau/ranch/blob/v0/LICENSE_BOOST
[LICENSE\_MIT]: https://github.com/AldaronLau/ranch/blob/v0/LICENSE_MIT
[documentation]: https://docs.rs/ranch