[][src]Function bech32::convert_bits

pub fn convert_bits<T>(
    data: &[T],
    from: u32,
    to: u32,
    pad: bool
) -> Result<Vec<u8>, Error> where
    T: Into<u8> + Copy

Convert between bit sizes

Errors

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]);