#[non_exhaustive]pub struct Pattern {
pub value: u8,
pub mask: u8,
}
Expand description
BytePattern
Given a target byte, the pattern will set bits to corresponding bits from value
according to mask
.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.value: u8
§mask: u8
Implementations§
Trait Implementations§
Source§impl BytePattern for Pattern
impl BytePattern for Pattern
Source§fn eval(&self, value: u8) -> u8
fn eval(&self, value: u8) -> u8
Returns the value with current pattern applied.
use bswp::BytePattern;
use bswp::pattern::Pattern;
let byte_pattern = Pattern::new(0xFF).with_mask(0xF0);
assert_eq!(byte_pattern.eval(0x00), 0xF0);
let byte_pattern = Pattern::new(0b10101111).with_mask(0b10011010);
assert_eq!(byte_pattern.eval(0b00000000), 0b10001010);
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more