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:
parent
2063e61211
commit
dab8e5108a
1 changed files with 9 additions and 3 deletions
|
@ -135,10 +135,16 @@ impl<T: AsRef<str>> Render for PreEscaped<T> {
|
||||||
/// The `html!` macro expands to an expression of this type.
|
/// The `html!` macro expands to an expression of this type.
|
||||||
pub type Markup = PreEscaped<String>;
|
pub type Markup = PreEscaped<String>;
|
||||||
|
|
||||||
impl PreEscaped<String> {
|
impl<T: AsRef<str> + Into<String>> PreEscaped<T> {
|
||||||
/// Extracts the inner `String`. This is a synonym for `self.0`.
|
/// Converts the inner value to a string.
|
||||||
pub fn into_string(self) -> 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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue