mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 05:21:14 +00:00
Add missing #[inline]
annotations
This commit is contained in:
parent
bf5e066b68
commit
01e9d3c640
@ -161,6 +161,7 @@ pub trait Template: fmt::Display + FastWritable {
|
||||
}
|
||||
|
||||
impl<W: io::Write> fmt::Write for Wrapped<W> {
|
||||
#[inline]
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
if let Err(err) = self.writer.write_all(s.as_bytes()) {
|
||||
self.err = Some(err);
|
||||
@ -286,6 +287,7 @@ impl<T: Template> DynTemplate for T {
|
||||
<Self as Template>::render(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(feature = "alloc")]
|
||||
fn dyn_render_with_values(&self, values: &dyn Values) -> Result<String> {
|
||||
<Self as Template>::render_with_values(self, values)
|
||||
@ -296,6 +298,7 @@ impl<T: Template> DynTemplate for T {
|
||||
<Self as Template>::render_into(self, writer)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn dyn_render_into_with_values(
|
||||
&self,
|
||||
writer: &mut dyn fmt::Write,
|
||||
@ -304,6 +307,7 @@ impl<T: Template> DynTemplate for T {
|
||||
<Self as Template>::render_into_with_values(self, writer, values)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(feature = "std")]
|
||||
fn dyn_write_into(&self, writer: &mut dyn io::Write) -> io::Result<()> {
|
||||
<Self as Template>::write_into(self, writer)
|
||||
@ -513,6 +517,7 @@ const _: () = {
|
||||
}
|
||||
|
||||
impl FastWritable for fmt::Arguments<'_> {
|
||||
#[inline]
|
||||
fn write_into<W: fmt::Write + ?Sized>(
|
||||
&self,
|
||||
dest: &mut W,
|
||||
|
@ -7,11 +7,15 @@ use crate::Error;
|
||||
pub const NO_VALUES: &dyn Values = &();
|
||||
|
||||
/// Try to find `key` in `values` and then to convert it to `T`.
|
||||
#[inline]
|
||||
pub fn get_value<T: Any>(values: &dyn Values, key: impl AsRef<str>) -> Result<&T, Error> {
|
||||
let Some(src) = values.get_value(key.as_ref()) else {
|
||||
return Err(Error::ValueMissing);
|
||||
};
|
||||
values
|
||||
.get_value(key.as_ref())
|
||||
.ok_or(Error::ValueMissing)
|
||||
.and_then(convert_value)
|
||||
}
|
||||
|
||||
fn convert_value<T: Any>(src: &dyn Any) -> Result<&T, Error> {
|
||||
if let Some(value) = src.downcast_ref::<T>() {
|
||||
return Ok(value);
|
||||
} else if let Some(value) = src.downcast_ref::<&T>() {
|
||||
@ -90,6 +94,7 @@ where
|
||||
K: Borrow<str>,
|
||||
V: Value,
|
||||
{
|
||||
#[inline]
|
||||
fn get_value<'a>(&'a self, key: &str) -> Option<&'a dyn Any> {
|
||||
find_value_linear(self.iter(), key)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user