Skip to content

Commit

Permalink
Make simple forwarding methods #[inline]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Jan 13, 2025
1 parent 64ad242 commit a4527b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rinja/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,13 @@ pub trait DynTemplate {
}

impl<T: Template> DynTemplate for T {
#[inline]
#[cfg(feature = "alloc")]
fn dyn_render(&self) -> Result<String> {
<Self as Template>::render(self)
}

#[inline]
fn dyn_render_into(&self, writer: &mut dyn fmt::Write) -> Result<()> {
<Self as Template>::render_into(self, writer)
}
Expand All @@ -217,12 +219,14 @@ impl<T: Template> DynTemplate for T {
<Self as Template>::write_into(self, writer)
}

#[inline]
fn size_hint(&self) -> usize {
Self::SIZE_HINT
<Self as Template>::SIZE_HINT
}
}

impl fmt::Display for dyn DynTemplate {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.dyn_render_into(f).map_err(|_| fmt::Error {})
}
Expand Down

0 comments on commit a4527b8

Please sign in to comment.