You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
thanks for writing this nice library.
For some reason I thought I could use indextree as a graph structure. Later I realized that this library is just for tree structures. And I got such strange behavior:
let arena = &mutArena::new();let start = arena.new_node("start");let a = arena.new_node("A");let b = arena.new_node("b");let c = arena.new_node("c");
start.append(a, arena);
a.append(start, arena);
start.append(b, arena);
b.append(start, arena);assert_eq!(start.children(arena).into_iter().count(), 2);
a.append(c, arena);
c.append(a, arena);assert_eq!(start.children(arena).into_iter().count(), 2);//FAILED: count is 1
I guess doing "proper" validation to check if I'm building graph is difficult. For example this gives infinite look:
let arena = &mutArena::new();let a = arena.new_node("a");let b = arena.new_node("b");let c = arena.new_node("c");
a.append(b, arena);
b.append(c, arena);
c.append(a, arena);assert_eq!(a.children(arena).into_iter().count(), 1);assert_eq!(a.descendants(arena).into_iter().count(), 3);// infinite loop
But in my case just panic when trying to "connect" nodes to each other would give me earlier feedback that I'm using this library in a wrong way. I propose that for second append the code below should panic (I hope it's easy to check it, I didn't look at the source code)
let arena = &mutArena::new();let a = arena.new_node("a");let b = arena.new_node("b");
a.append(b, arena);
b.append(a, arena);//IMO this should panicassert_eq!(a.children(arena).into_iter().count(), 1);assert_eq!(a.descendants(arena).into_iter().count(), 2);// infinite loop
Hi,
thanks for writing this nice library.
For some reason I thought I could use
indextree
as a graph structure. Later I realized that this library is just for tree structures. And I got such strange behavior:I guess doing "proper" validation to check if I'm building graph is difficult. For example this gives infinite look:
But in my case just
panic
when trying to "connect" nodes to each other would give me earlier feedback that I'm using this library in a wrong way. I propose that for secondappend
the code below should panic (I hope it's easy to check it, I didn't look at the source code)BTW, the example code on https://crates.io/crates/indextree is not compiling (
assert!(a.append(b, arena).is_ok());
line)The text was updated successfully, but these errors were encountered: