From 278ec27b4e36fd9b8b97029c3048bd3258a21930 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Tue, 30 Apr 2024 22:05:15 -0400 Subject: [PATCH] Linting --- otg/core/src/types.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/otg/core/src/types.rs b/otg/core/src/types.rs index 7ce672b..c89b55c 100644 --- a/otg/core/src/types.rs +++ b/otg/core/src/types.rs @@ -4,7 +4,7 @@ use config_derive::ConfigOption; use serde::{Deserialize, Serialize}; use sgf::GameTree; use std::{ - cell::RefCell, collections::{HashMap, VecDeque}, fmt, ops::Deref, path::PathBuf, time::Duration + collections::{HashMap, VecDeque}, fmt, ops::Deref, path::PathBuf, time::Duration }; use thiserror::Error; @@ -254,9 +254,15 @@ impl Deref for DepthTree { #[derive(Debug)] pub struct SizeNode { - node_id: nary_tree::NodeId, - parent: Option, + /// Use this to map back to the node in the original game tree. This way we know how to + /// correspond from a node in the review tree back to there. + #[allow(dead_code)] + game_node_id: nary_tree::NodeId, + + /// How deep into the tree is this node? depth: usize, + + /// How far from the leftmost margin is this node? width: usize, } @@ -398,7 +404,7 @@ impl DepthTree { pub fn bfs_iter(&self) -> BFSIter<'_, SizeNode> { let mut queue = VecDeque::new(); queue.push_back(self.0.root().unwrap()); - BFSIter { tree: self, queue } + BFSIter { queue } } } @@ -425,8 +431,7 @@ impl<'a> From<&'a GameTree> for DepthTree { // this branch. let dest_root_id = tree.set_root(SizeNode { - node_id: source_root_node.node_id(), - parent: None, + game_node_id: source_root_node.node_id(), depth: 0, width: 0, }); @@ -441,8 +446,7 @@ impl<'a> From<&'a GameTree> for DepthTree { let mut dest_parent = tree.get_mut(*dest_parent_id).unwrap(); let new_depth_node = SizeNode { - node_id: source_node.node_id(), - parent: Some(*dest_parent_id), + game_node_id: source_node.node_id(), depth: 1 + dest_parent.data().depth, width: dest_parent.data().width, }; @@ -521,7 +525,6 @@ impl<'a> From<&'a GameNode> for Tree { */ pub struct BFSIter<'a, T> { - tree: &'a DepthTree, queue: VecDeque>, }