nodes/scalar: add data(), data_mut() methods
This commit is contained in:
parent
f82dabae9d
commit
12271d1c88
|
@ -5,7 +5,10 @@
|
|||
*/
|
||||
|
||||
use crate::{
|
||||
node::nodes::{NodeContext, NodeData, NodeIndex, NodeMark, NodeSpecific, Tag},
|
||||
node::{
|
||||
graph::Storage,
|
||||
nodes::{NodeContext, NodeData, NodeIndex, NodeMark, NodeSpecific, Tag},
|
||||
},
|
||||
token::{ScalarStyle, Slice},
|
||||
};
|
||||
|
||||
|
@ -52,6 +55,20 @@ impl<'de> ScalarNode<'de>
|
|||
self.parent
|
||||
}
|
||||
|
||||
pub fn data<'a>(&self, g: &'a Storage<'de>) -> ScalarDataRef<'a, 'de>
|
||||
{
|
||||
let data = &g.node_data()[self.id];
|
||||
|
||||
ScalarDataRef::new(data)
|
||||
}
|
||||
|
||||
pub fn data_mut<'a>(&self, g: &'a mut Storage<'de>) -> ScalarDataMut<'a, 'de>
|
||||
{
|
||||
let data = &mut g.node_data_mut()[self.id];
|
||||
|
||||
ScalarDataMut::new(data)
|
||||
}
|
||||
|
||||
fn with_parent(id: NodeIndex, scalar: Slice<'de>, parent: Option<NodeIndex>) -> Self
|
||||
{
|
||||
Self { parent, id, scalar }
|
||||
|
|
Loading…
Reference in New Issue