1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::Composer;
pub struct Recomposer {
pub(crate) composer: Composer,
}
impl Recomposer {
pub fn root<R: 'static>(&self) -> Option<&R> {
self.composer
.tape
.get(0)
.and_then(|s| s.data.as_ref().map(|d| d.as_ref().get_ref()))
.and_then(|n| n.as_any().downcast_ref::<R>())
}
pub fn root_mut<R: 'static>(&mut self) -> Option<&mut R> {
self.composer
.tape
.get_mut(0)
.and_then(|s| s.data.as_mut().map(|d| d.as_mut().get_mut()))
.and_then(|n| n.as_any_mut().downcast_mut::<R>())
}
pub fn compose(self) -> Composer {
self.composer
}
}