wip: update core for generic Render

This commit is contained in:
🪞👃🪞 2024-09-03 18:13:10 +03:00
parent fcd2d16de9
commit bf165c6be1
5 changed files with 68 additions and 62 deletions

View file

@ -59,3 +59,14 @@ impl<R, T, U> Render<T, U> for RwLock<R> where R: Render<T, U> {
self.read().unwrap().render(to)
}
}
/// Boxed closures can be rendered.
///
/// Rendering unboxed closures should also be possible;
/// but in practice implementing the trait for an unboxed
/// `Fn` closure causes an impl conflict.
impl<'a, T, U> Render<T, U> for Box<dyn Fn(&mut T) -> Perhaps<U> + Send + Sync + 'a> {
fn render (&self, to: &mut T) -> Perhaps<U> {
(*self)(to)
}
}