1
use crate::prelude::Commands;
2
use uniplate::Uniplate;
3

            
4
/// Represents the effects of a successful rule application.
5
///
6
/// Contains the new subtree and any side-effects. This type is not intended to be constructed
7
/// directly, but rather created by the engine to pass to the user-defined selector functions.
8
pub struct Update<T, M>
9
where
10
    T: Uniplate,
11
{
12
    pub(crate) new_subtree: T,
13
    pub(crate) commands: Commands<T, M>,
14
}
15

            
16
impl<T, M> Update<T, M>
17
where
18
    T: Uniplate,
19
{
20
    pub(crate) fn new(new_subtree: T, commands: Commands<T, M>) -> Self {
21
        Update {
22
            new_subtree,
23
            commands,
24
        }
25
    }
26

            
27
    /// The new subtree to be inserted as a result of applying this [`Update`].
28
    pub fn new_subtree(&self) -> &T {
29
        &self.new_subtree
30
    }
31
}