[][src]Function pir_8_emu::util::limit_to_width

pub fn limit_to_width<T: Num + PrimInt + CheckedShr>(
    number: T,
    bit_width: u8
) -> Option<T>

Limit the specified number to be at most the specified bit-width

Examples

assert_eq!(limit_to_width(0b0101, 3), Some(0b0101));

assert_eq!(limit_to_width(0b1010, 3), None);