You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In theory the existing signatures of Render/RenderOnce allow for more efficient code. But in practice we often end up just invoking html! and pushing that to the buffer. If this is the more common use case, then we should have these trait methods return Markup directly instead.
Something like this:
traitRender{fnrender(&self) -> Markup;// what .render() used to befnrender_to(&self,buffer:&mutString){
buffer.push_str(&self.render());}}// similarly for RenderOnce
Note that we still need .render_to() to optimize the blanket impl for T: Display, because write!(s, "{}", x) is much faster than x.to_string().
Example:
// shorthand for linking to a stylesheetstructStylesheet<S>(pubS);impl<S:AsRef<str>>RenderforStylesheet<S>{fnrender(&self) -> Markup{html!{
link rel="stylesheet"type="text/css" href=(self.0.as_ref()) /
}}}
The text was updated successfully, but these errors were encountered:
In theory the existing signatures of
Render
/RenderOnce
allow for more efficient code. But in practice we often end up just invokinghtml!
and pushing that to the buffer. If this is the more common use case, then we should have these trait methods returnMarkup
directly instead.Something like this:
Note that we still need
.render_to()
to optimize the blanket impl forT: Display
, becausewrite!(s, "{}", x)
is much faster thanx.to_string()
.Example:
The text was updated successfully, but these errors were encountered: