Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl Default for PreEscaped #371

Merged
merged 3 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, String::from(""));
lambda-fairy marked this conversation as resolved.
Show resolved Hide resolved
assert_eq!(PreEscaped::<&'static str>::default().0, "");
}