diff --git a/rinja/src/filters/escape.rs b/rinja/src/filters/escape.rs index 9ff4e9de3..eb5372748 100644 --- a/rinja/src/filters/escape.rs +++ b/rinja/src/filters/escape.rs @@ -188,12 +188,12 @@ pub trait AutoEscape { /// Used internally by rinja to select the appropriate escaper #[derive(Debug, Clone)] -pub struct AutoEscaper<'a, T: fmt::Display + ?Sized, E: Escaper> { +pub struct AutoEscaper<'a, T: ?Sized, E> { text: &'a T, escaper: E, } -impl<'a, T: fmt::Display + ?Sized, E: Escaper> AutoEscaper<'a, T, E> { +impl<'a, T: ?Sized, E> AutoEscaper<'a, T, E> { #[inline] pub fn new(text: &'a T, escaper: E) -> Self { Self { text, escaper } @@ -275,7 +275,7 @@ impl<'a, T: HtmlSafe + ?Sized> AutoEscape for &AutoEscaper<'a, T, Html> { /// "
", /// ); /// ``` -pub enum MaybeSafe { +pub enum MaybeSafe { Safe(T), NeedsEscaping(T), } @@ -313,16 +313,12 @@ const _: () = { add_ref!([] [&] [&&] [&&&]); - pub enum Wrapped<'a, T: fmt::Display + ?Sized, E: Escaper> { + pub enum Wrapped<'a, T: ?Sized, E> { Safe(&'a T), NeedsEscaping(&'a T, E), } - impl FastWritable for Wrapped<'_, T, E> - where - T: AsRef + fmt::Display + ?Sized, - E: Escaper, - { + impl + ?Sized, E: Escaper> FastWritable for Wrapped<'_, T, E> { #[inline] fn write_into(&self, dest: &mut W) -> fmt::Result { match self { @@ -381,7 +377,7 @@ const _: () = { /// "
", /// ); /// ``` -pub struct Safe(pub T); +pub struct Safe(pub T); const _: () = { // This is the fallback. The filter is not the last element of the filter chain. @@ -394,8 +390,7 @@ const _: () = { macro_rules! add_ref { ($([$($tt:tt)*])*) => { $( - impl<'a, T: fmt::Display, E: Escaper> AutoEscape - for &AutoEscaper<'a, $($tt)* Safe, E> { + impl<'a, T: fmt::Display, E> AutoEscape for &AutoEscaper<'a, $($tt)* Safe, E> { type Escaped = &'a T; type Error = Infallible; @@ -411,7 +406,7 @@ const _: () = { }; /// There is not need to mark the output of a custom filter as "unsafe"; this is simply the default -pub struct Unsafe(pub T); +pub struct Unsafe(pub T); impl fmt::Display for Unsafe { #[inline] @@ -421,7 +416,7 @@ impl fmt::Display for Unsafe { } /// Like [`Safe`], but only for HTML output -pub struct HtmlSafeOutput(pub T); +pub struct HtmlSafeOutput(pub T); impl fmt::Display for HtmlSafeOutput { #[inline]