Skip to content

Commit bc842b9

Browse files
metamuffinutkarshkukreti
authored andcommitted
implement Render for Cow types
1 parent c1dc693 commit bc842b9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

markup/src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,32 @@ impl<T: RenderAttributeValue + ?Sized> RenderAttributeValue for Box<T> {
7373
}
7474
}
7575

76+
impl<'a, T: Render + ToOwned + ?Sized> Render for std::borrow::Cow<'a, T> {
77+
#[inline]
78+
fn render(&self, writer: &mut impl std::fmt::Write) -> std::fmt::Result {
79+
T::render(self, writer)
80+
}
81+
}
82+
83+
impl<'a, T: RenderAttributeValue + ToOwned + ?Sized> RenderAttributeValue
84+
for std::borrow::Cow<'a, T>
85+
{
86+
#[inline]
87+
fn is_none(&self) -> bool {
88+
T::is_none(self)
89+
}
90+
91+
#[inline]
92+
fn is_true(&self) -> bool {
93+
T::is_true(self)
94+
}
95+
96+
#[inline]
97+
fn is_false(&self) -> bool {
98+
T::is_false(self)
99+
}
100+
}
101+
76102
impl Render for bool {
77103
#[inline]
78104
fn render(&self, writer: &mut impl std::fmt::Write) -> std::fmt::Result {

0 commit comments

Comments
 (0)