pub trait LowMask {
// Required method
fn low_mask(bits: u64) -> Self;
}
Expand description
Returns a number whose least significant $b$ bits are true
and whose other bits are false
.
Required Methods§
Object Safety§
Implementations on Foreign Types§
source§impl LowMask for i8
impl LowMask for i8
source§fn low_mask(bits: u64) -> i8
fn low_mask(bits: u64) -> i8
Returns a number whose least significant $b$ bits are true
and whose other bits
are false
.
$$ f(b) = \begin{cases} 2^b - 1 & \text{if} \quad 0 \leq n < W, \\ -1 & \text{if} \quad n = W, \end{cases} $$ where $W$ is the width of the type.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if bits
is greater than the width of the type.
§Examples
See here.
source§impl LowMask for i16
impl LowMask for i16
source§fn low_mask(bits: u64) -> i16
fn low_mask(bits: u64) -> i16
Returns a number whose least significant $b$ bits are true
and whose other bits
are false
.
$$ f(b) = \begin{cases} 2^b - 1 & \text{if} \quad 0 \leq n < W, \\ -1 & \text{if} \quad n = W, \end{cases} $$ where $W$ is the width of the type.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if bits
is greater than the width of the type.
§Examples
See here.
source§impl LowMask for i32
impl LowMask for i32
source§fn low_mask(bits: u64) -> i32
fn low_mask(bits: u64) -> i32
Returns a number whose least significant $b$ bits are true
and whose other bits
are false
.
$$ f(b) = \begin{cases} 2^b - 1 & \text{if} \quad 0 \leq n < W, \\ -1 & \text{if} \quad n = W, \end{cases} $$ where $W$ is the width of the type.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if bits
is greater than the width of the type.
§Examples
See here.
source§impl LowMask for i64
impl LowMask for i64
source§fn low_mask(bits: u64) -> i64
fn low_mask(bits: u64) -> i64
Returns a number whose least significant $b$ bits are true
and whose other bits
are false
.
$$ f(b) = \begin{cases} 2^b - 1 & \text{if} \quad 0 \leq n < W, \\ -1 & \text{if} \quad n = W, \end{cases} $$ where $W$ is the width of the type.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if bits
is greater than the width of the type.
§Examples
See here.
source§impl LowMask for i128
impl LowMask for i128
source§fn low_mask(bits: u64) -> i128
fn low_mask(bits: u64) -> i128
Returns a number whose least significant $b$ bits are true
and whose other bits
are false
.
$$ f(b) = \begin{cases} 2^b - 1 & \text{if} \quad 0 \leq n < W, \\ -1 & \text{if} \quad n = W, \end{cases} $$ where $W$ is the width of the type.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if bits
is greater than the width of the type.
§Examples
See here.
source§impl LowMask for isize
impl LowMask for isize
source§fn low_mask(bits: u64) -> isize
fn low_mask(bits: u64) -> isize
Returns a number whose least significant $b$ bits are true
and whose other bits
are false
.
$$ f(b) = \begin{cases} 2^b - 1 & \text{if} \quad 0 \leq n < W, \\ -1 & \text{if} \quad n = W, \end{cases} $$ where $W$ is the width of the type.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if bits
is greater than the width of the type.
§Examples
See here.