Skip to content

Commit

Permalink
fix: panic in traverse method if the tree is empty (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
antouhou authored Jun 19, 2024
1 parent 7e42bf4 commit cad3881
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "easy-tree"
version = "0.1.1"
version = "0.1.2"
authors = ["Anton Suprunchuk <[email protected]>"]
edition = "2021"
description = "A simple and efficient tree structure library for Rust with recursive traversal"
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ impl<T> Tree<T> {
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() {
Expand Down

0 comments on commit cad3881

Please sign in to comment.