use crate::node::{Arena, Node, NodeId};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Document {
arena: Arena,
root: NodeId,
}
impl Document {
#[must_use]
pub fn new(arena: Arena, root: NodeId) -> Self {
Self { arena, root }
}
#[must_use]
pub fn arena(&self) -> &Arena {
&self.arena
}
#[must_use]
pub fn root(&self) -> NodeId {
self.root
}
#[must_use]
pub fn with_arena(self, arena: Arena) -> Self {
Self { arena, ..self }
}
#[must_use]
pub fn get(&self, id: NodeId) -> Option<&Node> {
self.arena.get(id)
}
}