Add impl Into<String> for PreEscaped

This allows for passing `Markup` values directly to Rouille's
[`Response::html`][1] constructor.

[1]: https://docs.rs/rouille/0.4.1/rouille/struct.Response.html#method.html
This commit is contained in:
Chris Wong 2016-12-17 13:41:59 +13:00
parent 2063e61211
commit dab8e5108a

View file

@ -135,10 +135,16 @@ impl<T: AsRef<str>> Render for PreEscaped<T> {
/// The `html!` macro expands to an expression of this type.
pub type Markup = PreEscaped<String>;
impl PreEscaped<String> {
/// Extracts the inner `String`. This is a synonym for `self.0`.
impl<T: AsRef<str> + Into<String>> PreEscaped<T> {
/// Converts the inner value to a string.
pub fn into_string(self) -> String {
self.0
self.0.into()
}
}
impl<T: AsRef<str> + Into<String>> Into<String> for PreEscaped<T> {
fn into(self) -> String {
self.into_string()
}
}