Skip to content
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

make register reader/writer copiable, return writer #738

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

burrbull
Copy link
Member

@burrbull burrbull commented Jul 6, 2023

cc @rust-embedded/tools
Do anyone see disadvantage of using value instead of mutable reference for writer?

Related to #708

Big breaking change.

This does not let you create writer outside of write as suggested by #708, but lets to reuse of writer.

for example
this

apb.rstr().modify(|_, w| w.$perrst().set_bit());
apb.rstr().modify(|_, w| w.$perrst().clear_bit());

can be optimized to

let w = apb.rstr().modify(|_, w| w.$perrst().set_bit());
apb.rstr().write(|_| w.$perrst().clear_bit());

R<REG> -> W<REG> conversion could be added also. Unsafe?

@thejpster
Copy link
Contributor

That seems like you could get yourself into trouble (accidentally using a w from the function scope not the closure argument, or saving a w and not using for a call, then using it again after and losing your changes).

Is there any evidence that what we have is inefficient?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants