aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2022-01-06 14:48:27 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2022-01-06 15:36:25 +0100
commit803d32cd46245d72884ad1b251964906fd50dd00 (patch)
tree2f6e13c85b17ceaf1bded0727dae20afb37b2131 /askama_shared/src/generator.rs
parent8b4cc660a95d7ffa2d3f03efcea36048a425e762 (diff)
downloadaskama-803d32cd46245d72884ad1b251964906fd50dd00.tar.gz
askama-803d32cd46245d72884ad1b251964906fd50dd00.tar.bz2
askama-803d32cd46245d72884ad1b251964906fd50dd00.zip
Add `#[inline]` to trivial trait implementations
Diffstat (limited to 'askama_shared/src/generator.rs')
-rw-r--r--askama_shared/src/generator.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs
index b891d89..5c6303c 100644
--- a/askama_shared/src/generator.rs
+++ b/askama_shared/src/generator.rs
@@ -180,6 +180,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
"type Target = {};",
parent_type.into_token_stream()
))?;
+ buf.writeln("#[inline]")?;
buf.writeln("fn deref(&self) -> &Self::Target {")?;
buf.writeln("&self._parent")?;
buf.writeln("}")?;
@@ -189,6 +190,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
// Implement `Display` for the given context struct.
fn impl_display(&mut self, buf: &mut Buffer) -> Result<(), CompileError> {
self.write_header(buf, "::std::fmt::Display", None)?;
+ buf.writeln("#[inline]")?;
buf.writeln("fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {")?;
buf.writeln("::askama::Template::render_into(self, f).map_err(|_| ::std::fmt::Error {})")?;
buf.writeln("}")?;
@@ -199,6 +201,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
fn impl_actix_web_responder(&mut self, buf: &mut Buffer) -> Result<(), CompileError> {
self.write_header(buf, "::actix_web::Responder", None)?;
buf.writeln("type Body = ::actix_web::body::BoxBody;")?;
+ buf.writeln("#[inline]")?;
buf.writeln(
"fn respond_to(self, _req: &::actix_web::HttpRequest) \
-> ::actix_web::web::HttpResponse<Self::Body> {",
@@ -211,6 +214,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
// Implement Axum's `IntoResponse`.
fn impl_axum_into_response(&mut self, buf: &mut Buffer) -> Result<(), CompileError> {
self.write_header(buf, "::askama_axum::IntoResponse", None)?;
+ buf.writeln("#[inline]")?;
buf.writeln(
"fn into_response(self)\
-> ::askama_axum::Response<::askama_axum::BoxBody> {",
@@ -224,6 +228,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
// Implement gotham's `IntoResponse`.
fn impl_gotham_into_response(&mut self, buf: &mut Buffer) -> Result<(), CompileError> {
self.write_header(buf, "::askama_gotham::IntoResponse", None)?;
+ buf.writeln("#[inline]")?;
buf.writeln(
"fn into_response(self, _state: &::askama_gotham::State)\
-> ::askama_gotham::Response<::askama_gotham::Body> {",
@@ -293,6 +298,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
Some(vec![param]),
)?;
+ buf.writeln("#[inline]")?;
buf.writeln(
"fn respond_to(self, _: &::askama_rocket::Request) \
-> ::askama_rocket::Result<'askama> {",
@@ -315,6 +321,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
)?;
buf.writeln(
"type Error = ::askama_tide::askama::Error;\n\
+ #[inline]\n\
fn try_into(self) -> ::askama_tide::askama::Result<::askama_tide::tide::Body> {",
)?;
buf.writeln(&format!("::askama_tide::try_into_body(&self, {:?})", &ext))?;
@@ -323,6 +330,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
buf.writeln("#[allow(clippy::from_over_into)]")?;
self.write_header(buf, "Into<::askama_tide::tide::Response>", None)?;
+ buf.writeln("#[inline]")?;
buf.writeln("fn into(self) -> ::askama_tide::tide::Response {")?;
buf.writeln(&format!("::askama_tide::into_response(&self, {:?})", ext))?;
buf.writeln("}\n}")
@@ -330,6 +338,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
fn impl_warp_reply(&mut self, buf: &mut Buffer) -> Result<(), CompileError> {
self.write_header(buf, "::askama_warp::warp::reply::Reply", None)?;
+ buf.writeln("#[inline]")?;
buf.writeln("fn into_response(self) -> ::askama_warp::warp::reply::Response {")?;
let ext = self.input.extension().unwrap_or("txt");
buf.writeln(&format!("::askama_warp::reply(&self, {:?})", ext))?;