Put specialized impls in a logical order (#205)
Follow-up to #204 cc @berwyn
This commit is contained in:
parent
f85e7b500b
commit
a495522259
1 changed files with 12 additions and 12 deletions
|
@ -76,16 +76,17 @@ pub trait Render {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg(not(feature = "unstable"))]
|
||||
impl<T: fmt::Display + ?Sized> Render for T {
|
||||
default fn render_to(&self, w: &mut String) {
|
||||
fn render_to(&self, w: &mut String) {
|
||||
let _ = write!(Escaper::new(w), "{}", self);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: AsRef<str>> Render for PreEscaped<T> {
|
||||
fn render_to(&self, w: &mut String) {
|
||||
w.push_str(self.0.as_ref());
|
||||
#[cfg(feature = "unstable")]
|
||||
impl<T: fmt::Display + ?Sized> Render for T {
|
||||
default fn render_to(&self, w: &mut String) {
|
||||
let _ = write!(Escaper::new(w), "{}", self);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,17 +104,16 @@ impl Render for str {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "unstable"))]
|
||||
impl<T: fmt::Display + ?Sized> Render for T {
|
||||
fn render_to(&self, w: &mut String) {
|
||||
let _ = write!(Escaper::new(w), "{}", self);
|
||||
}
|
||||
}
|
||||
|
||||
/// A wrapper that renders the inner value without escaping.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct PreEscaped<T: AsRef<str>>(pub T);
|
||||
|
||||
impl<T: AsRef<str>> Render for PreEscaped<T> {
|
||||
fn render_to(&self, w: &mut String) {
|
||||
w.push_str(self.0.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
/// A block of markup is a string that does not need to be escaped.
|
||||
///
|
||||
/// The `html!` macro expands to an expression of this type.
|
||||
|
|
Loading…
Add table
Reference in a new issue