### Define Macro-Generated Bounded Integer in Rust Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Demonstrates how to define a custom bounded integer type using the `bounded_integer!` macro in Rust, specifying its valid range. The example shows creating an instance and asserting its value. ```Rust bounded_integer! { struct MyInteger { 0..8 } } let num = MyInteger::new(5).unwrap(); assert_eq!(num, 5); ``` -------------------------------- ### Enable `alloc` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Enables interoperability with the `alloc` crate, providing support for indexing `Vec` and `VecDeque` with const-generic integers. ```APIDOC alloc: Interopate with `alloc`. - Support for indexing with the const-generic integers on `Vec` and `VecDeque`. ``` -------------------------------- ### Enable `macro` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Enables the `bounded_integer!` macro for convenient bounded integer definition. ```APIDOC macro: Enable the [`bounded_integer!`] macro. ``` -------------------------------- ### Enable `zerocopy` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Implements `IntoBytes` for all bounded integers and `Unaligned` for macro-generated ones, facilitating zero-copy operations. ```APIDOC zerocopy: Implement [`IntoBytes`] for all bounded integers, and [`Unaligned`] for macro-generated ones. ``` -------------------------------- ### Enable `step_trait` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Implements the `Step` trait, allowing bounded integers to be used easily in ranges. Requires a nightly Rust toolchain and `#![feature(step_trait)]` in the crate root if using the macro. ```APIDOC step_trait: Implement the [`Step`] trait which allows the bounded integers to be easily used in ranges. This will require you to use nightly and place `#![feature(step_trait)]` in your crate root if you use the macro. ``` -------------------------------- ### Enable `serde1` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Implements `Serialize` and `Deserialize` for bounded integers, ensuring values remain within bounds during serialization/deserialization. This feature has a deprecated alias `serde`. ```APIDOC serde1: Implement [`Serialize`] and [`Deserialize`] for the bounded integers, making sure all values will never be out of bounds. This has a deprecated alias `serde`. ``` -------------------------------- ### Enable `bytemuck1` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Implements the `Contiguous` trait for all bounded integers and `Zeroable` for macro-generated ones that support it, enabling low-level byte manipulation. ```APIDOC bytemuck1: Implement [`Contiguous`] for all bounded integers, and [`Zeroable`] for macro-generated bounded integers that support it. ``` -------------------------------- ### Enable `num-traits02` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Implements various numeric traits from `num-traits` for const-generic bounded integers, including `Bounded`, `AsPrimitive`, `FromPrimitive`, `NumCast`, `ToPrimitive`, and checked/saturating arithmetic operations. ```APIDOC num-traits02: Implement [`Bounded`], [`AsPrimitive`], [`FromPrimitive`], [`NumCast`], [`ToPrimitive`], [`CheckedAdd`], [`CheckedDiv`], [`CheckedMul`], [`CheckedNeg`], [`CheckedRem`], [`CheckedSub`], [`MulAdd`], [`SaturatingAdd`], [`SaturatingMul`] and [`SaturatingSub`] for all const-generic bounded integers. ``` -------------------------------- ### Enable `arbitrary1` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Implements the `Arbitrary` trait for bounded integers, useful for fuzzing inputs. ```APIDOC arbitrary1: Implement [`Arbitrary`] for the bounded integers. This is useful when using bounded integers as fuzzing inputs. ``` -------------------------------- ### Enable `types` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Enables the bounded integer types that utilize Rust's const generics. ```APIDOC types: Enable the bounded integer types that use const generics. ``` -------------------------------- ### Create Const Generics-Based Bounded Integer in Rust Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Illustrates how to create an ad-hoc bounded integer using const generics types like `BoundedU8` in Rust. This method is concise and interoperable but has limitations with certain traits. ```Rust let num = >::new(5).unwrap(); assert_eq!(num, 5); ``` -------------------------------- ### Enable `std` feature for Bounded Integer Crate Source: https://github.com/kestrer/bounded-integer/blob/main/README.md Enables interoperability with the Rust standard library, implying `alloc` support. Provides an implementation of the `Error` trait for `ParseError`. ```APIDOC std: Interopate with `std` — implies `alloc`. - An implementation of [`Error`] for [`ParseError`]. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.