Crate setbits

Source
Expand description

Create an unsigned integer with the high/low n bits set to 1

All functions are const

This crate can be particularly useful for creating bit masks

§Features

The inline feature is enabled by default and inlines all the functions with a suggestion that they should be inline (#[inline])

§Attribution

Original code for setbits_u32_lo taken from: https://users.rust-lang.org/t/how-to-make-an-integer-with-n-bits-set-without-overflow/63078/3

Functions§

setbits_u8_hi
Create a u8 with the high n bits set to 1
setbits_u8_lo
Create a u8 with the low n bits set to 1
setbits_u16_hi
Create a u16 with the high n bits set to 1
setbits_u16_lo
Create a u16 with the low n bits set to 1
setbits_u32_hi
Create a u32 with the high n bits set to 1
setbits_u32_lo
Create a u32 with the low n bits set to 1
setbits_u64_hi
Create a u64 with the high n bits set to 1
setbits_u64_lo
Create a u64 with the low n bits set to 1
setbits_u128_hi
Create a u128 with the high n bits set to 1
setbits_u128_lo
Create a u128 with the low n bits set to 1