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
290977
    pub(crate) fn new(new_subtree: T, commands: Commands<T, M>) -> Self {
21
290977
        Update {
22
290977
            new_subtree,
23
290977
            commands,
24
290977
        }
25
290977
    }
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

            
32
1432
    pub(crate) fn has_transform(&self) -> bool {
33
1432
        self.commands.has_transform()
34
1432
    }
35
}