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 Nov 1, 2024
1 parent 23f0e88 commit c02b251
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rinja/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,33 +201,39 @@ pub trait DynTemplate {
}

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

#[inline]
fn dyn_render_into(&self, writer: &mut dyn fmt::Write) -> Result<()> {
<Self as Template>::render_into(self, writer)
Self::render_into(self, writer)
}

#[inline]
fn dyn_write_into(&self, writer: &mut dyn io::Write) -> io::Result<()> {
<Self as Template>::write_into(self, writer)
Self::write_into(self, writer)
}

#[inline]
fn extension(&self) -> Option<&'static str> {
Self::EXTENSION
}

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

#[inline]
fn mime_type(&self) -> &'static str {
Self::MIME_TYPE
}
}

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 c02b251

Please sign in to comment.