diff --git a/CHANGELOG.md b/CHANGELOG.md index 6abacc9..c3ffaf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# [0.1.2](https://github.com/antouhou/easy-tree/compare/v0.1.1...v0.1.2) (2024-06-19) + + +### Fixes + +* fix panic on empty tree traversal ([#4](https://github.com/antouhou/easy-tree/pull/4)) + + # [0.1.1](https://github.com/antouhou/easy-tree/compare/v0.1.0...v0.1.1) (2024-06-03) diff --git a/Cargo.lock b/Cargo.lock index 82db66d..56e6c06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,7 +29,7 @@ checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "easy-tree" -version = "0.1.1" +version = "0.1.2" dependencies = [ "rayon", ] diff --git a/Cargo.toml b/Cargo.toml index d0d08a2..bcb936f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "easy-tree" -version = "0.1.1" +version = "0.1.2" authors = ["Anton Suprunchuk "] edition = "2021" description = "A simple and efficient tree structure library for Rust with recursive traversal" diff --git a/src/lib.rs b/src/lib.rs index a0e5933..426ce31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,6 +209,10 @@ impl Tree { mut after_processing_the_subtree: impl FnMut(usize, &'a T, &mut S), s: &mut S, ) { + if self.is_empty() { + return; + } + let mut stack = vec![(0, false)]; while let Some((index, children_visited)) = stack.pop() {