use std::{fmt, ops::Deref};
pub struct RawHtml {
html: Box<str>,
}
impl RawHtml {
pub fn trusted(html: impl Into<String>) -> RawHtml {
let html = html.into().into_boxed_str();
RawHtml { html }
}
pub fn as_str(&self) -> &str {
&self.html
}
}
impl Deref for RawHtml {
type Target = str;
fn deref(&self) -> &str {
&self.html
}
}
impl Clone for RawHtml {
fn clone(&self) -> Self {
RawHtml::trusted(&*self.html)
}
}
impl PartialEq for RawHtml {
fn eq(&self, other: &Self) -> bool {
self.html == other.html
}
}
impl Eq for RawHtml {}
impl fmt::Debug for RawHtml {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("RawHtml").field(&&*self.html).finish()
}
}