Chaining set_*
methods in registers
#755
romancardenas
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone!
First of all, I thought that it would be a nice idea to use Discussions for this topic. If you prefer an issue, let me know and I'll set up one.
@jsgf is working on a PR for
riscv
that adds a fewset_*
methods for read values of themstatus
register. I suggested following thecortex-m
approach, in which these functions look likefn set_*(&mut self, val: T)
. However, he proposed using afn set_*(&mut self, val: T) -> &mut Self
fashion, so users could chain setter methods when configuring a register with multiple fields. I think this is a nice approach, but wanted to share it with the rest of the WG in case anyone has any objection (or if thecortex-m
team would like to adopt this proposal too).Beta Was this translation helpful? Give feedback.
All reactions