Skip to content

Commit e2f2702

Browse files
committed
tock-registers: rename TryFromValue::try_from to try_from_value
1 parent d1a6ee1 commit e2f2702

File tree

1 file changed

+8
-8
lines changed
  • libraries/tock-register-interface/src

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<T: UIntLike, R: RegisterLongName> Field<T, R> {
102102
#[inline]
103103
/// Read value of the field as an enum member
104104
pub fn read_as_enum<E: TryFromValue<T, EnumType = E>>(self, val: T) -> Option<E> {
105-
E::try_from(self.read(val))
105+
E::try_from_value(self.read(val))
106106
}
107107
}
108108

@@ -252,7 +252,7 @@ impl<T: UIntLike, R: RegisterLongName> AddAssign for FieldValue<T, R> {
252252
pub trait TryFromValue<V> {
253253
type EnumType;
254254

255-
fn try_from(v: V) -> Option<Self::EnumType>;
255+
fn try_from_value(v: V) -> Option<Self::EnumType>;
256256
}
257257

258258
/// Helper macro for computing bitmask of variable number of bits
@@ -366,7 +366,7 @@ macro_rules! register_bitmasks {
366366
impl TryFromValue<$valtype> for Value {
367367
type EnumType = Value;
368368

369-
fn try_from(v: $valtype) -> Option<Self::EnumType> {
369+
fn try_from_value(v: $valtype) -> Option<Self::EnumType> {
370370
match v {
371371
$(
372372
$(#[$inner])*
@@ -417,7 +417,7 @@ macro_rules! register_bitmasks {
417417
impl TryFromValue<$valtype> for Value {
418418
type EnumType = Value;
419419

420-
fn try_from(_v: $valtype) -> Option<Self::EnumType> {
420+
fn try_from_value(_v: $valtype) -> Option<Self::EnumType> {
421421
Option::None
422422
}
423423
}
@@ -470,14 +470,14 @@ mod tests {
470470
impl crate::fields::TryFromValue<u16> for Foo {
471471
type EnumType = Foo;
472472

473-
fn try_from(v: u16) -> Option<Self::EnumType> {
474-
Self::try_from(v as u32)
473+
fn try_from_value(v: u16) -> Option<Self::EnumType> {
474+
Self::try_from_value(v as u32)
475475
}
476476
}
477477
impl crate::fields::TryFromValue<u32> for Foo {
478478
type EnumType = Foo;
479479

480-
fn try_from(v: u32) -> Option<Self::EnumType> {
480+
fn try_from_value(v: u32) -> Option<Self::EnumType> {
481481
match v {
482482
0 => Some(Foo::Foo0),
483483
1 => Some(Foo::Foo1),
@@ -556,7 +556,7 @@ mod tests {
556556
for shift in 0..29 {
557557
let field = Field::<u32, ()>::new(0x7, shift);
558558
for x in 0..8 {
559-
assert_eq!(field.read_as_enum(x << shift), Foo::try_from(x));
559+
assert_eq!(field.read_as_enum(x << shift), Foo::try_from_value(x));
560560
}
561561
}
562562
}

0 commit comments

Comments
 (0)