pub fn convert_bits<T>(
    data: &[T],
    from: u32,
    to: u32,
    pad: bool,
) -> Result<Vec<u8>, Error>Expand description
Convert between bit sizes
§Errors
- Error::InvalidDataif any element of- datais out of range
- Error::InvalidPaddingif- pad == falseand the padding bits are not- 0
§Panics
Function will panic if attempting to convert from or to a bit size that
is 0 or larger than 8 bits.
§Examples
use bech32::convert_bits;
let base5 = convert_bits(&[0xff], 8, 5, true);
assert_eq!(base5.unwrap(), vec![0x1f, 0x1c]);