Skip to content

Commit e33b403

Browse files
committed
Don't consume self in mask()/matches_all()/matches_any()
These operations don't require completely consuming self.
1 parent 674fbd7 commit e33b403

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libraries/tock-register-interface/src/registers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ FieldValue_impl_for!(u128);
584584

585585
impl<T: IntLike, R: RegisterLongName> FieldValue<T, R> {
586586
/// Get the raw bitmask represented by this FieldValue.
587-
pub fn mask(self) -> T {
587+
pub fn mask(&self) -> T {
588588
self.mask as T
589589
}
590590

@@ -599,12 +599,12 @@ impl<T: IntLike, R: RegisterLongName> FieldValue<T, R> {
599599
}
600600

601601
/// Check if any specified parts of a field match
602-
pub fn matches_any(self, val: T) -> bool {
602+
pub fn matches_any(&self, val: T) -> bool {
603603
val & self.mask != T::zero()
604604
}
605605

606606
/// Check if all specified parts of a field match
607-
pub fn matches_all(self, val: T) -> bool {
607+
pub fn matches_all(&self, val: T) -> bool {
608608
val & self.mask == self.value
609609
}
610610
}

0 commit comments

Comments
 (0)