Remove AsRef<str> restriction from structs ()

This commit is contained in:
Imbolc 2023-05-28 17:11:37 +06:00 committed by GitHub
parent ca7b93c790
commit 1ab01cca27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View file

@ -2,6 +2,9 @@
## [Unreleased]
- Remove `AsRef<str>` restriction from `PreEscaped`
[#377](https://github.com/lambda-fairy/maud/pull/377)
## [0.25.0] - 2023-04-16
- Remove `html_debug!`

View file

@ -64,7 +64,7 @@ use maud::{Markup, PreEscaped, Render};
use pulldown_cmark::{Parser, html};
/// Renders a block of Markdown using `pulldown-cmark`.
struct Markdown<T: AsRef<str>>(T);
struct Markdown<T>(T);
impl<T: AsRef<str>> Render for Markdown<T> {
fn render(&self) -> Markup {

View file

@ -215,7 +215,7 @@ pub fn display(value: impl Display) -> impl Render {
/// A wrapper that renders the inner value without escaping.
#[derive(Debug, Clone, Copy)]
pub struct PreEscaped<T: AsRef<str>>(pub T);
pub struct PreEscaped<T>(pub T);
impl<T: AsRef<str>> Render for PreEscaped<T> {
fn render_to(&self, w: &mut String) {
@ -228,20 +228,20 @@ impl<T: AsRef<str>> Render for PreEscaped<T> {
/// The `html!` macro expands to an expression of this type.
pub type Markup = PreEscaped<String>;
impl<T: AsRef<str> + Into<String>> PreEscaped<T> {
impl<T: Into<String>> PreEscaped<T> {
/// Converts the inner value to a string.
pub fn into_string(self) -> String {
self.0.into()
}
}
impl<T: AsRef<str> + Into<String>> From<PreEscaped<T>> for String {
impl<T: Into<String>> From<PreEscaped<T>> for String {
fn from(value: PreEscaped<T>) -> String {
value.into_string()
}
}
impl<T: AsRef<str> + Default> Default for PreEscaped<T> {
impl<T: Default> Default for PreEscaped<T> {
fn default() -> Self {
Self(Default::default())
}