lazy-bytes-cast

Build Crates.io Docs.rs

This crate provides simple methods to cast from and into byte arrays.

Example

```rust use lazybytescast::{FromBytes, IntoBytes, readu32, readu64, readu128, readu16, ReadBytes};

let val = 9999999u32; let bytes = [127u8, 150, 152, 0]; let mut bytesslice = &bytes[..]; asserteq!(val.into_bytes(), bytes);

asserteq!(u32::frombytes(bytes), val); asserteq!(u32::frombytes(bytes), readu32(&bytes, 0)); asserteq!(u32::frombytes(bytes), bytesslice.readvalue::().unwrap()); asserteq!(bytesslice.len(), 0); assert!(bytesslice.readvalue::().isnone());

asserteq!(readu16(&u16::maxvalue().tonebytes(), 0), u16::maxvalue()); asserteq!(readu64(&u64::maxvalue().tonebytes(), 0), u64::maxvalue()); asserteq!(readu128(&u128::maxvalue().tonebytes(), 0), u128::maxvalue()); ```