tree_morph/
update.rs

1use crate::prelude::Commands;
2use 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.
8pub struct Update<T, M>
9where
10    T: Uniplate,
11{
12    pub(crate) new_subtree: T,
13    pub(crate) commands: Commands<T, M>,
14}
15
16impl<T, M> Update<T, M>
17where
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}