From 2ef37517be24a72dc16b3da8937e2fa83e835e2f Mon Sep 17 00:00:00 2001 From: imbolc Date: Fri, 24 Mar 2023 16:10:30 +0600 Subject: [PATCH 1/3] impl Default for PreEscaped --- maud/src/lib.rs | 6 ++++++ maud/tests/misc.rs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/maud/src/lib.rs b/maud/src/lib.rs index 9c4a1809..800098bd 100644 --- a/maud/src/lib.rs +++ b/maud/src/lib.rs @@ -241,6 +241,12 @@ impl + Into> From> for String { } } +impl + Default> Default for PreEscaped { + fn default() -> Self { + Self(Default::default()) + } +} + /// The literal string ``. /// /// # Example diff --git a/maud/tests/misc.rs b/maud/tests/misc.rs index b9aae522..242bad6c 100644 --- a/maud/tests/misc.rs +++ b/maud/tests/misc.rs @@ -130,3 +130,10 @@ fn prefer_render_over_display() { "<display>" ); } + +#[test] +fn default() { + use maud::{Markup, PreEscaped}; + assert_eq!(Markup::default().0, String::from("")); + assert_eq!(PreEscaped::<&'static str>::default().0, ""); +} From fc07713e26b4e8c27dada8713b90310362d23a98 Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Sun, 16 Apr 2023 15:22:14 +1000 Subject: [PATCH 2/3] Simplify assertion --- maud/tests/misc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maud/tests/misc.rs b/maud/tests/misc.rs index 242bad6c..4f6752b6 100644 --- a/maud/tests/misc.rs +++ b/maud/tests/misc.rs @@ -134,6 +134,6 @@ fn prefer_render_over_display() { #[test] fn default() { use maud::{Markup, PreEscaped}; - assert_eq!(Markup::default().0, String::from("")); + assert_eq!(Markup::default().0, ""); assert_eq!(PreEscaped::<&'static str>::default().0, ""); } From 21afd8897cac9552760d38c84593078c1093afbc Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Sun, 16 Apr 2023 15:24:01 +1000 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93c665d0..351bbc78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ [#357](https://github.com/lambda-fairy/maud/pull/357) - Support `axum` v0.6 through `axum-core` v0.3 [#361](https://github.com/lambda-fairy/maud/pull/361) +- Implement `Default` for `PreEscaped` + [#371](https://github.com/lambda-fairy/maud/pull/371) ## [0.24.0] - 2022-08-12