@@ -270,10 +270,18 @@ impl Tree {
270270 })
271271 }
272272
273+ /// Get reference to a [`view`] by index.
274+ /// # Panics
275+ ///
276+ /// Panics if `index` is not in self.nodes, or if the node's content is not [`Content::View`] . This can be checked with [`contains`]
273277 pub fn get(&self, index: ViewId) -> &View {
274278 self.try_get(index).unwrap()
275279 }
276280
281+ /// Try to get reference to a [`view`] by index. Returns `None` if node content is not a [`Content::View`]
282+ /// # Panics
283+ ///
284+ /// Panics if `index` is not in self.nodes. This can be checked with [`Self::contains`]
277285 pub fn try_get(&self, index: ViewId) -> Option<&View> {
278286 match &self.nodes[index] {
279287 Node {
@@ -284,6 +292,10 @@ impl Tree {
284292 }
285293 }
286294
295+ /// Get a mutable reference to a [`view`] by index.
296+ /// # Panics
297+ ///
298+ /// Panics if `index` is not in self.nodes, or if the node's content is not [`Content::View`] . This can be checked with [`Self::contains`]
287299 pub fn get_mut(&mut self, index: ViewId) -> &mut View {
288300 match &mut self.nodes[index] {
289301 Node {
@@ -294,6 +306,11 @@ impl Tree {
294306 }
295307 }
296308
309+ /// Check if tree contains a [`Node`] with a given index.
310+ pub fn contains(&self, index: ViewId) -> bool {
311+ self.nodes.contains_key(index)
312+ }
313+
297314 pub fn is_empty(&self) -> bool {
298315 match &self.nodes[self.root] {
299316 Node {