From b7e5768d44dc28e7c017a25c17b6898f82e329c2 Mon Sep 17 00:00:00 2001 From: Imbolc Date: Sun, 28 May 2023 17:38:14 +0600 Subject: [PATCH] Impl Render for Arc (#380) * Arc * Changelog --- CHANGELOG.md | 2 ++ maud/src/lib.rs | 8 +++++++- maud/tests/misc.rs | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 279b9cbd..c1d91020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Remove `AsRef` restriction from `PreEscaped` [#377](https://github.com/lambda-fairy/maud/pull/377) +- Implement `Render` for `Arc` + [#380](https://github.com/lambda-fairy/maud/pull/380) ## [0.25.0] - 2023-04-16 diff --git a/maud/src/lib.rs b/maud/src/lib.rs index 1b8c494f..53aa3fa9 100644 --- a/maud/src/lib.rs +++ b/maud/src/lib.rs @@ -11,7 +11,7 @@ extern crate alloc; -use alloc::{borrow::Cow, boxed::Box, string::String}; +use alloc::{borrow::Cow, boxed::Box, string::String, sync::Arc}; use core::fmt::{self, Arguments, Display, Write}; pub use maud_macros::html; @@ -150,6 +150,12 @@ impl Render for Box { } } +impl Render for Arc { + fn render_to(&self, w: &mut String) { + T::render_to(self, w); + } +} + macro_rules! impl_render_with_display { ($($ty:ty)*) => { $( diff --git a/maud/tests/misc.rs b/maud/tests/misc.rs index 4f6752b6..1a775725 100644 --- a/maud/tests/misc.rs +++ b/maud/tests/misc.rs @@ -137,3 +137,9 @@ fn default() { assert_eq!(Markup::default().0, ""); assert_eq!(PreEscaped::<&'static str>::default().0, ""); } + +#[test] +fn render_arc() { + let arc = std::sync::Arc::new("foo"); + assert_eq!(html! { (arc) }.into_string(), "foo"); +}