Skip to content

Commit 8a1de57

Browse files
committed
tock-registers: Add none method rather than implementing Default.
As requested in code review.
1 parent 56ac7aa commit 8a1de57

File tree

1 file changed

+10
-1
lines changed
  • libraries/tock-register-interface/src

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Field_impl_for!(usize);
190190
///
191191
/// For the FieldValue, the masks and values are shifted into their actual
192192
/// location in the register.
193-
#[derive(Copy, Clone, Default, Eq, PartialEq)]
193+
#[derive(Copy, Clone, Eq, PartialEq)]
194194
pub struct FieldValue<T: UIntLike, R: RegisterLongName> {
195195
mask: T,
196196
pub value: T,
@@ -230,6 +230,15 @@ FieldValue_impl_for!(u128);
230230
FieldValue_impl_for!(usize);
231231

232232
impl<T: UIntLike, R: RegisterLongName> FieldValue<T, R> {
233+
#[inline]
234+
pub fn none() -> Self {
235+
Self {
236+
mask: T::zero(),
237+
value: T::zero(),
238+
associated_register: PhantomData,
239+
}
240+
}
241+
233242
/// Get the raw bitmask represented by this FieldValue.
234243
#[inline]
235244
pub fn mask(&self) -> T {

0 commit comments

Comments
 (0)