-
-
Notifications
You must be signed in to change notification settings - Fork 779
tock-register-interface: Provide none method for FieldValue type.
#3013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Default is useful to construct a FieldValue which can be passed to `modify` as a no-op or used as an additive identity when combining other FieldValues. Eq and PartialEq are useful for assertions in testing.
3755003 to
fd5687d
Compare
|
I don't see the benefit of having a first-class additive identity for Also, I'm not convinced we should make |
|
There are several usecases I see for
registers.reg.write(REG::default());(Yes, I realise you could just use
let mut field_values = REG::default();
if some_condition {
field_values += REG::FIELD::SET;
}
if some_other_condition {
field_values += REG::OTHER_FIELD::SET;
}
registers.reg.modify(field_values);As for |
Derive Copy, Clone, Eq and PartialEq for generated field value enums.
|
Okay, I see the benefit of having a default implementation for |
|
Implementing the |
|
I agree, |
|
I might even recommend |
|
Done. |
Could you perhaps remove this change from this PR? I'm still not 100% convinced on that and it seems it wouldn't be a major inconvenience to you to just compare the mask and the read value (in conjuction with the corresponding |
As requested in code review.
Code reviewers don't like it.
e6e4a3a to
bbc58e6
Compare
|
Done. |
none method for FieldValue type.
|
bors r+ |
`tock-registers` now supports stable Rust! There is a small breaking change, documented below, required to support Rust 2021 edition. Most of the remaining changes are improvements to the internal self-testing infrastructure and documentation. There are also some additions to `FieldValue` to improve ergonomics. **Breaking Changes** - #2842: tock-registers: rename TryFromValue::try_from to try_from_value - #2833: Update to Rust 2021 edition Other Changes - #3126: [trivial] tock-registers: mark two methods as `const` - #3088: tock_registers/test_fields: respect struct size padding w/ alignment - #3072: Update Rust nightly version + Expose virtual-function-elimination - libraries/tock-register-interface: Fixup register_structs documentation - #2988: Remove const_fn_trait_bound feature and update nightly (Mar 2022) - #3014: tock-registers: Implement From field enum value type for FieldValue - #3013: tock-register-interface: Provide none method for FieldValue type - #2916: tock-register-interface: improve read_as_enum documentation - #2922: tock-register-interface: replace register tests by const assertions
`tock-registers` now supports stable Rust! There is a small breaking change, documented below, required to support Rust 2021 edition. Most of the remaining changes are improvements to the internal self-testing infrastructure and documentation. There are also some additions to `FieldValue` to improve ergonomics. **Breaking Changes** - #2842: tock-registers: rename TryFromValue::try_from to try_from_value - #2833: Update to Rust 2021 edition Other Changes - #3126: [trivial] tock-registers: mark two methods as `const` - #3088: tock_registers/test_fields: respect struct size padding w/ alignment - #3072: Update Rust nightly version + Expose virtual-function-elimination - libraries/tock-register-interface: Fixup register_structs documentation - #2988: Remove const_fn_trait_bound feature and update nightly (Mar 2022) - #3014: tock-registers: Implement From field enum value type for FieldValue - #3013: tock-register-interface: Provide none method for FieldValue type - #2916: tock-register-interface: improve read_as_enum documentation - #2922: tock-register-interface: replace register tests by const assertions
`tock-registers` now supports stable Rust! There is a small breaking change, documented below, required to support Rust 2021 edition. Most of the remaining changes are improvements to the internal self-testing infrastructure and documentation. There are also some additions to `FieldValue` to improve ergonomics. **Breaking Changes** - #2842: tock-registers: rename TryFromValue::try_from to try_from_value - #2838: Update to Rust 2021 edition Other Changes - #3126: [trivial] tock-registers: mark two methods as `const` - #3088: tock_registers/test_fields: respect struct size padding w/ alignment - #3072: Update Rust nightly version + Expose virtual-function-elimination - libraries/tock-register-interface: Fixup register_structs documentation - #2988: Remove const_fn_trait_bound feature and update nightly (Mar 2022) - #3014: tock-registers: Implement From field enum value type for FieldValue - #3013: tock-register-interface: Provide none method for FieldValue type - #2916: tock-register-interface: improve read_as_enum documentation - #2922: tock-register-interface: replace register tests by const assertions
3151: tock-registers: release v0.8 r=lschuermann a=ppannuto ### Pull Request Overview Prepare a v0.8 release of tock-registers. Fixes #2982. --- `tock-registers` now supports stable Rust! There is a small breaking change, documented below, required to support Rust 2021 edition. Most of the remaining changes are improvements to the internal self-testing infrastructure and documentation. There are also some additions to `FieldValue` to improve ergonomics. **Breaking Changes** - #2842: tock-registers: rename TryFromValue::try_from to try_from_value - #2838: Update to Rust 2021 edition Other Changes - #3126: [trivial] tock-registers: mark two methods as `const` - #3088: tock_registers/test_fields: respect struct size padding w/ alignment - #3072: Update Rust nightly version + Expose virtual-function-elimination - libraries/tock-register-interface: Fixup register_structs documentation - #2988: Remove const_fn_trait_bound feature and update nightly (Mar 2022) - #3014: tock-registers: Implement From field enum value type for FieldValue - #3013: tock-register-interface: Provide none method for FieldValue type - #2916: tock-register-interface: improve read_as_enum documentation - #2922: tock-register-interface: replace register tests by const assertions ### Testing Strategy N/A ### TODO or Help Wanted N/A ### Documentation Updated - [x] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [ ] Ran `make prepush`. Co-authored-by: Pat Pannuto <[email protected]>
Pull Request Overview
Defaultis useful to construct aFieldValuewhich can be passed tomodifyas a no-op or used as an additive identity when combining otherFieldValues.EqandPartialEqare useful for assertions in testing.Testing Strategy
This pull request was tested by
cargo test.Documentation Updated
/docs, or no updates are required.Formatting
make prepush.