Skip to content

Commit

Permalink
more tests, miri fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KGrewal1 committed Nov 22, 2024
1 parent 93f8338 commit 8a0b246
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
4 changes: 2 additions & 2 deletions tree_arena/src/tree_arena_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct DataMap<T> {
/// The parent of each node, or None if it is the root
parents: HashMap<NodeId, Option<NodeId>>,
/// The roots of the tree
roots: UnsafeCell<Vec<NodeId>>,
roots: Box<UnsafeCell<Vec<NodeId>>>,
}

/// A container type for a tree of items.
Expand Down Expand Up @@ -118,7 +118,7 @@ impl<T> DataMap<T> {
Self {
items: HashMap::new(),
parents: HashMap::new(),
roots: UnsafeCell::new(Vec::new()),
roots: Box::new(UnsafeCell::new(Vec::new())),
}
}

Expand Down
23 changes: 0 additions & 23 deletions tree_arena/tests/basic_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,3 @@ fn mem_swap() {
assert_eq!(*node_1_item, 'c', "Node 1 item should be 'c'");
assert_eq!(*node_2_item, 'd', "Node 2 item should be 'd'");
}

// #[test]
// fn mem_swap() {
// let mut tree_a: TreeArena<char> = TreeArena::new();
// let mut roots_a = tree_a.root_token_mut();
// roots_a.insert_child(1_u64, 'a');
// let mut node_1a = roots_a.get_child_mut(1_u64).expect("No child 1 found");
// node_1a.children.insert_child(2_u64, 'b');
// let node_1a_item = node_1a.item;

// let mut tree_b: TreeArena<char> = TreeArena::new();
// let mut roots_b = tree_b.root_token_mut();
// roots_b.insert_child(1_u64, 'c');
// let mut node_1b = roots_b.get_child_mut(1_u64).expect("No child 1 found");
// node_1b.children.insert_child(2_u64, 'd');
// let node_1b_item = node_1b.item;

// std::mem::swap(&mut node_1a.children, &mut node_1b.children);

// let node_1b_swapped = tree_b.find(1_u64).expect("No child 1 found");

// let c = node_1a_item;
// }

0 comments on commit 8a0b246

Please sign in to comment.