wplot/abs/
changer.rs

1/// Internal namespace.
2pub( crate ) mod private
3{
4  use crate::protected::*;
5
6  /// Context.
7  pub trait ChangerInterface
8  where
9    Self :
10      fmt::Debug +
11      Clone +
12    ,
13  {
14    /// Type of root changer.
15    type Root : ChangerInterface;
16    /// Type of parent changer.
17    type Parent : ChangerInterface;
18
19    /// Get root.
20    #[ inline ]
21    fn root( &mut self ) -> &mut Self::Root
22    {
23      // Safaty : that's safe becuase root type is the same for all nodes.
24      unsafe
25      {
26        core::mem::transmute::< _, _ >( self.parent().root() )
27      }
28    }
29
30    /// Get back to root changer.
31    fn context( self ) -> Self::Root;
32
33    /// Get parent.
34    fn parent( &mut self ) -> &mut Self::Parent;
35
36    /// Get back to parent changer.
37    fn end( self ) -> Self::Parent;
38
39    /// Add change.
40    #[ inline ]
41    fn change_add< Change >( &mut self, change : Change ) -> &mut Self
42    where
43      Change : ChangeInterface + 'static,
44    {
45      self.root().change_add( change );
46      self
47    }
48
49  }
50
51}
52
53crate::mod_interface!
54{
55
56  prelude use ChangerInterface;
57
58}