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
Improve ATOM constants naming #429
Comments
If backwards-compatibility is a concern, I would suggest adding a module |
…and only after trying to solve this issue I found that Well, that's a lot nicer to use, but at the very least, I would like to see the documentation for this crate to be improved in this regard (for now). This might mean adding a tiny guide on the main page of the documentation saying "when matching on tags, you likely want to use this". Future work: that guide should show the basics on parsing HTML, which is what most people probably want to do. |
Maybe provide something like this, perhaps have the macro_rules! make_tag_consts {
( $( $tag:tt => $constant:ident ),* ) => {
$(
const $constant: string_cache::Atom<html5ever::LocalNameStaticSet> =
html5ever::local_name!($tag);
)*
};
}
make_tag_consts!(
"a" => TAG_A,
"href" => ATTR_HREF
); Otherwise, users need to depend on Honestly I think the synonyms should be provided by |
@Lonami Hi. What are the benefits of using Using constants probably won't help with importing |
It's semantically clearer what one means, since macros can do pretty much anything after all. But my original issue was that the constants were bad and I had no idea The current docstring for the macro reads:
It's not very obvious (at least to me) that this can be used in the match arms when matching against tag names. |
Yeah, I'm definitely for clearer docs. And maybe allowing constants for easier reference is ok. That said. I just don't see how exporting these constants will save you from importing |
I depended on |
The current naming is bad:
This would be a lot better:
Having to do this isn't pretty :)
We could go further and use naming like
TAG_A
,TAG_B
, but this gets tricky if there are attributes (not tags) that share names with tags. Maybe justATOM_A
? TheLOCALNAME
feels redundant.The text was updated successfully, but these errors were encountered: