Skip to content

Commit

Permalink
impl Default for PreEscaped (#371)
Browse files Browse the repository at this point in the history
* impl Default for PreEscaped

* Simplify assertion

* Update CHANGELOG.md

---------

Co-authored-by: Chris Wong <[email protected]>
  • Loading branch information
imbolc and lambda-fairy authored Apr 16, 2023
1 parent 0d1bc32 commit 34b3bc0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions maud/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ impl<T: AsRef<str> + Into<String>> From<PreEscaped<T>> for String {
}
}

impl<T: AsRef<str> + Default> Default for PreEscaped<T> {
fn default() -> Self {
Self(Default::default())
}
}

/// The literal string `<!DOCTYPE html>`.
///
/// # Example
Expand Down
7 changes: 7 additions & 0 deletions maud/tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,10 @@ fn prefer_render_over_display() {
"&lt;display&gt;"
);
}

#[test]
fn default() {
use maud::{Markup, PreEscaped};
assert_eq!(Markup::default().0, "");
assert_eq!(PreEscaped::<&'static str>::default().0, "");
}

0 comments on commit 34b3bc0

Please sign in to comment.