Skip to content

Commit

Permalink
Added: Render for Option<T> & ExactSizeIterator where I::Item: AsRef<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
re-oh committed Oct 10, 2024
1 parent c9a81e8 commit 409ab09
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions maud/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ impl<T: Render + ?Sized> Render for Arc<T> {
}
}

impl<T: Render + ?Sized> Render for Option<T> {
fn render_to(&self, w: &mut String) { if let Some(inner) = self { T::render_to(inner, w); } }
}

impl <T: Render + ?Sized, I: ExactSizeIterator + ?Sized> Render for I where I::Item: AsRef<T> {
fn render_to(&self, w: &mut String) {
for item in self {
item.as_ref().render_to(w);
}
}
}

macro_rules! impl_render_with_display {
($($ty:ty)*) => {
$(
Expand Down

0 comments on commit 409ab09

Please sign in to comment.