From c56101816d0fe6534ef9849f6136f0b3083cc122 Mon Sep 17 00:00:00 2001 From: Vidhan Bhatt Date: Fri, 12 Jan 2024 08:27:10 -0500 Subject: [PATCH] chore: add Cow Renderable impl --- hypertext/src/alloc.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hypertext/src/alloc.rs b/hypertext/src/alloc.rs index e930122..26d22ac 100644 --- a/hypertext/src/alloc.rs +++ b/hypertext/src/alloc.rs @@ -1,6 +1,6 @@ extern crate alloc; -use alloc::string::String; +use alloc::{borrow::Cow, string::String}; use core::fmt::{self, Display, Write}; /// Generate HTML using [`maud`] syntax. @@ -310,6 +310,13 @@ impl Renderable for String { } } +impl Renderable for Cow<'_, str> { + #[inline] + fn render_to(self, output: &mut String) { + html_escape::encode_single_quoted_attribute_to_string(self, output); + } +} + impl Renderable for bool { #[inline] fn render_to(self, output: &mut String) {