1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
use crate::{ComposeNode, Composer};
use std::any::Any;
pub struct Recomposer<N: ?Sized> {
pub(crate) composer: Composer<N>,
}
impl<N> Recomposer<N>
where
N: 'static + ?Sized + Any + Unpin,
for<'a> &'a mut N: ComposeNode,
{
pub fn root_mut(&mut self) -> Option<&mut N> {
self.composer
.tape
.get_mut(0)
.and_then(|s| s.data.as_mut().map(|d| d.as_mut().get_mut()))
}
pub fn compose(self) -> Composer<N> {
self.composer
}
}