pub trait BitRangeExt<T> {
// Required methods
fn get_mask(&self) -> T;
fn is_valid(&self) -> bool;
// Provided method
fn check(&self) { ... }
}
Expand description
Trait containing helper methods for BitRange
The methods are needed for:
- checking if the
BitRange
is valid for a typeT
- creating masks for a type
T
Required Methods§
Sourcefn get_mask(&self) -> T
fn get_mask(&self) -> T
Returns a value of type T
that has all the bits in the specified bit range set to 1.
§Example
#[macro_use]
use dbs_arch::cpuid::bit_helper::*;
let range = BitRange {
msb_index: 7,
lsb_index: 3,
};
println!("binary value: {:b}", range.get_mask());
The code above will print:
binary value: 11111000