Allow non-mutable access to Document nodes

This commit is contained in:
Simon Ask Ulsnes 2024-02-04 10:05:48 +01:00
parent 5b9dcd7a15
commit 0d9097344a

View file

@ -115,10 +115,17 @@ impl Document {
/// Get a node of a YAML document.
///
/// Returns the node object or `None` if `index` is out of range.
pub fn get_node(&mut self, index: i32) -> Option<&mut Node> {
pub fn get_node_mut(&mut self, index: i32) -> Option<&mut Node> {
self.nodes.get_mut(index as usize - 1)
}
/// Get a node of a YAML document.
///
/// Returns the node object or `None` if `index` is out of range.
pub fn get_node(&self, index: i32) -> Option<&Node> {
self.nodes.get(index as usize - 1)
}
/// Get the root of a YAML document node.
///
/// The root object is the first object added to the document.