From 34b3bc00ce549edc13fb9dad3e3a7425a2a2177a Mon Sep 17 00:00:00 2001 From: Imbolc Date: Sun, 16 Apr 2023 11:27:45 +0600 Subject: [PATCH] impl Default for PreEscaped (#371) * impl Default for PreEscaped * Simplify assertion * Update CHANGELOG.md --------- Co-authored-by: Chris Wong --- CHANGELOG.md | 2 ++ maud/src/lib.rs | 6 ++++++ maud/tests/misc.rs | 7 +++++++ 3 files changed, 15 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 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..4f6752b6 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, ""); + assert_eq!(PreEscaped::<&'static str>::default().0, ""); +}