-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow boolean & update error for byte literals in html!
#3441
Allow boolean & update error for byte literals in html!
#3441
Conversation
Visit the preview URL for this PR (updated for commit 558b30c): https://yew-rs-api--pr3441-allow-more-literals-ppr0g8os.web.app (expires Sat, 04 Nov 2023 18:38:54 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size Comparison
✅ None of the examples has changed their size significantly. |
Benchmark - SSRYew Master
Pull Request
|
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.
Since the VDOM API supports it, I don't see why the macro shouldn't. Thanks for the PR!
GH actions should not have approved this
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.
I'm not sure why/how a byte would be useful? A byte is literally a u8, so it's converting b'a'
to the string "97"
?
It would indeed be strange to use a byte literal in HTML, but who knows what use cases are there in the wild, I think it would be even more strange to pretend like it's not stringifiable at compile-time. |
That is a valid point. What if we improved the diagnostic instead of just saying "invalid type"? |
I did just that for byte-string literals in this PR, the only Rust literal kind that generates a non- |
Lit::Float(v) => v.base10_digits().into(), | ||
Lit::Bool(v) => if v.value() { "true" } else { "false" }.into(), | ||
Lit::ByteStr(v) => String::from_utf8(v.value()).ok()?.into(), | ||
Lit::Byte(v) => v.value().to_string().into(), |
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 is similar to ByteStr
, however since a byte is u8 and u8 supports Display
.
So I am not sure not allowing b'A'
would be effective.
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.
Thanks! LGTM.
html!
html!
I'm sorry it took me this long to merge this |
Description
Adds support for the following usage of the
html!
macro: