Skip to content

Commit

Permalink
improved error message, outruled byte-string to HTML conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
its-the-shrimp committed Oct 28, 2023
1 parent b12f4b6 commit 11c1824
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/yew-macro/src/html_tree/html_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ impl Parse for HtmlNode {
Lit::ByteStr(lit) => {
return Err(syn::Error::new(
lit.span(),
"byte-strings can't be converted to HTML text\nnote: remove the `b` prefix",
"byte-strings can't be converted to HTML text
note: remove the `b` prefix or convert this to a `String`",
))
}
Lit::Verbatim(lit) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/yew-macro/src/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ impl Stringify for Lit {
Lit::Int(v) => v.base10_digits().into(),
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(),
Lit::Verbatim(v) => v.to_string().into(),
Lit::Verbatim(_) | Lit::ByteStr(_) => return None,
_ => unreachable!("unknown Lit {:?}", self),
};
Some(LitStr::new(&s, self.span()))
Expand Down

0 comments on commit 11c1824

Please sign in to comment.