Conversation
|
Thanks for your contribution. Will review and test and get back to you asap |
|
I merged a patch that will execute tests for PRs (like this). Would you mind rebasing to tip of tree? |
|
I can do that |
bitbybit-tests/src/bitfield_tests.rs
Outdated
| @@ -1,3 +1,6 @@ | |||
| use core::fmt; | |||
There was a problem hiding this comment.
this causes a warning when building the tests
bitbybit/src/bitfield/mod.rs
Outdated
| .collect(); | ||
| debug_trait.append_all(quote! { | ||
| impl core::fmt::Debug for #struct_name { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
There was a problem hiding this comment.
this should be core::fmt::Formatter. This crate user might be no_std
There was a problem hiding this comment.
Actually, I think that might bring its own problems for users that are using std. I think we need a way to figure out whether to use std or core. No idea how we would do that though - we could use the non-qualified name I guess? But that would be annoying to use.
There was a problem hiding this comment.
Nevermind what I said before, I just tried it out. Using ::core::fmt::Debug should always work, both in no_std and std projects.
There was a problem hiding this comment.
Oh, good catch.. it might be a good idea to have some sort of test for no_std compatiblity. The easiest way is a dedicated no_std app which is checked by CI
There was a problem hiding this comment.
I added a no_std check
|
Thank you for going above and beyond. This is excellent! |
test-no-std/src/main.rs
Outdated
| @@ -0,0 +1,12 @@ | |||
| #![no_std] #![no_main] | |||
|
|
|||
| #[bitbybit::bitfield(u32)] | |||
There was a problem hiding this comment.
Could you add debug and default? Those both require using traits from std
There was a problem hiding this comment.
Oh you already did. I'll go ahead and merge this
This adds a debug attribute, which generates a simple Debug implementation which forwards to the inner fields.
I also did a little bit of refactoring for the parsing of the attributes to be more
synlike :) THis is based on the syn docs: https://docs.rs/syn/latest/syn/meta/fn.parser.htmlI also added a small example. I think this is really useful for dev purposes, because I have a concrete example target I can
cargo expandfor bugfinding. It might also be useful for users.Some other things I noticed:
In the README, refer to the docs on docs.rs, or use a docs.rs badge :)
in general is added, can this be done just in the
bitfieldcrate?