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
Impl UUID macro #543
Impl UUID macro #543
Conversation
#[cfg(any(feature = "std", test))] | ||
#[macro_use] | ||
extern crate std; | ||
|
||
#[cfg(all(not(feature = "std"), not(test)))] | ||
#[macro_use] | ||
extern crate core as std; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required to stop shared/error.rs
and shared/parser.rs
from complaining. I just copy-pasted it from uuid
.
Thanks for working on this @QnnOkabayashi! I think we might need to wrap this up in a It would also be great to test this using Is this something you’d be interested in exploring further? If not I’m happy to merge and fill those bits in. Thanks again! 🙇 |
Done 👍
Done 👍 Also since the macro is integrated with the crate now, I was able to use the internal diagnostic information in the
If there's an invalid group length, it points to that group
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks @QnnOkabayashi!
I should've merged this one ahead of my changes to our benches. I just renamed some of the files. We probably don't really need benches for the uuid!
macro, since it should be "free" 🙂
Besides the merge conflict this should be ready to go now. |
Should be good to go now! |
I'm submitting a feature
Description
Implementing the
uuid!
macro for parsing string literals at compile time.Motivation
Very convenient for config files
Tests
I duplicated the valid str parsing tests for
uuid!()
, and they all compiled. For testing for failure, I checked that invalid inputs don't work:uuid!(struct)
fails properly.uuid!(44)
fails properly.uuid!("hello world")
fails properlyI didn't bother to test more extensively then that, do we care?
Also, can someone verify that tokenizing to
::uuid::Uuid::from_bytes([#tokens])
is hygienic?Related Issue(s)
#422