Add #[derive(VolatileFieldAccess)] for easy, access-limited field-based access to structs#49
Merged
phil-opp merged 1 commit intorust-osdev:mainfrom Apr 21, 2024
Merged
Conversation
phil-opp
reviewed
Apr 21, 2024
Member
phil-opp
left a comment
There was a problem hiding this comment.
Thanks a lot, this is really nice! I like having getter-like methods instead of macro invocations and I think rust-analyzer works better this way too.
My motivation for this is that I found map_field! not ideal to use when your field is nested (map_field!(one.two.three) does not work) and it does not chain well (cannot be nested).
I opened #50 with an attempt to remove this limitation. Maybe you could take a quick look?
… to structs Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
Member
Author
|
I have also slightly refactored the macro implementation (parsing into one struct instead of many) and have made the macro copy the docs from struct to trait. |
phil-opp
approved these changes
Apr 21, 2024
Member
|
Thanks a lot! Should I create a new release or do you have other changes planned that we should wait for? |
Member
Author
#[derive(Volatile)] for easy, access-limited field-based access to structs#[derive(VolatileFieldAccess)] for easy, access-limited field-based access to structs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new proc-macro that adds additional functions to
VolatilePtrfor user-defined types, with support for access-limitations.This means this code
will derive this code:
My motivation for this is that I found
map_field!not ideal to use when your field is nested (map_field!(one.two.three)does not work) and it does not chain well (cannot be nested).Additionally, this proc-macro allows you to properly specify access restrictions for your fields.
I thought this would be a nice fit for this repository rather than publishing the crate independently, for visibility, discoverability, and maintenance.
What are your thoughts on this?
This PR depends on #47