Impl Render for Arc<Render> ()

* Arc

* Changelog
This commit is contained in:
Imbolc 2023-05-28 17:38:14 +06:00 committed by GitHub
parent 1ab01cca27
commit b7e5768d44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View file

@ -4,6 +4,8 @@
- Remove `AsRef<str>` restriction from `PreEscaped`
[#377](https://github.com/lambda-fairy/maud/pull/377)
- Implement `Render` for `Arc<T>`
[#380](https://github.com/lambda-fairy/maud/pull/380)
## [0.25.0] - 2023-04-16

View file

@ -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<T: Render + ?Sized> Render for Box<T> {
}
}
impl<T: Render + ?Sized> Render for Arc<T> {
fn render_to(&self, w: &mut String) {
T::render_to(self, w);
}
}
macro_rules! impl_render_with_display {
($($ty:ty)*) => {
$(

View file

@ -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");
}