Allow boolean & update error for byte literals in html!#3441
Allow boolean & update error for byte literals in html!#3441ranile merged 4 commits intoyewstack:masterfrom
html!#3441Conversation
|
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 ComparisonDetails
✅ None of the examples has changed their size significantly. |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
ranile
left a comment
There was a problem hiding this comment.
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
cecton
left a comment
There was a problem hiding this comment.
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.
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.
html!html!
|
I'm sorry it took me this long to merge this |
Description
Adds support for the following usage of the
html!macro: