Function ebml_iterable::tools::arr_to_u64 [−][src]
pub fn arr_to_u64(arr: &[u8]) -> Result<u64, ToolError>
Expand description
Reads a u64 value from any length array slice.
Rather than forcing the input to be a [u8; 8] like standard library methods, this can interpret a u64 from a slice of any length < 8. Bytes are assumed to be least significant when reading the value - i.e. an array of [4, 0] would return a value of 1024. Will return an error if the input slice has a length > 8.
Example
let result = arr_to_u64(&[16,0])?; assert_eq!(result, 4096);