This crate provides simple methods to cast from and into byte arrays.
The crates will not take care of byte order for you. Cuz lazy.
```rust extern crate lazybytescast; use lazybytescast::slice::{ ByteSlice, ByteIndex };
fn main() { let some_int = 666;
for (idx, byte) in some_int.byte_slice().iter().enumerate() {
assert_eq!(some_int.byte(idx).unwrap(), *byte);
println!("bytes[{}]={}", idx, byte);
}
} ```
```rust extern crate lazybytescast; use lazybytescast::from::{ bytes_cast };
fn main() { let bytes = vec![127, 150, 152, 0];
if let Some(int) = bytes_cast::<u32>(&bytes) {
println!("bytes={:?}", bytes);
}
else {
println!("Couldn't extract integer from bytes");
}
} ```
```rust extern crate lazybytescast; use lazybytescast::to::{ ToBytesCast };
fn main() { let some_int = 666;
let bytes = some_int.to_bytes();
println!("bytes={:?}", bytes);
} ```