Set up the game review page along with #229

Merged
savanni merged 24 commits from otg/game-review into main 2024-03-31 23:37:51 +00:00
3 changed files with 7 additions and 7 deletions
Showing only changes of commit 0a62c96b0f - Show all commits

View File

@ -354,7 +354,7 @@ impl<T> Tree<T> {
width
}
pub fn bfs_iter<'a>(&'a self) -> BFSIter<T> {
pub fn bfs_iter(&self) -> BFSIter<T> {
let mut queue = VecDeque::new();
queue.push_back(&self.nodes[0]);
BFSIter { tree: self, queue }
@ -363,7 +363,7 @@ impl<T> Tree<T> {
impl<'a> From<&'a GameNode> for Tree<Uuid> {
fn from(root: &'a GameNode) -> Self {
fn add_subtree<'a>(tree: &mut Tree<Uuid>, parent_idx: usize, node: &'a GameNode) {
fn add_subtree(tree: &mut Tree<Uuid>, parent_idx: usize, node: &GameNode) {
let idx = tree.add_node(parent_idx, node.id());
let children = match node {
@ -401,7 +401,7 @@ impl<'a, T> Iterator for BFSIter<'a, T> {
fn next(&mut self) -> Option<Self::Item> {
let retval = self.queue.pop_front();
if let Some(ref retval) = retval {
if let Some(retval) = retval {
retval
.children
.iter()

View File

@ -18,7 +18,7 @@ use cairo::Context;
use glib::Object;
use gtk::{prelude::*, subclass::prelude::*};
use otg_core::Tree;
use sgf::{GameNode, GameRecord};
use sgf::GameRecord;
use std::{cell::RefCell, rc::Rc};
use uuid::Uuid;

View File

@ -121,7 +121,7 @@ impl GameRecord {
pub fn mainline(&self) -> Vec<&GameNode> {
let mut moves: Vec<&GameNode> = vec![];
let mut next = self.children.get(0);
let mut next = self.children.first();
while let Some(node) = next {
// Given that I know that I have a node, and I know that I'm going to push a reference
// to it onto my final list, I want to get the first of its children. And I want to
@ -136,8 +136,8 @@ impl GameRecord {
moves.push(node);
next = match node {
GameNode::MoveNode(node) => node.children.get(0),
GameNode::SetupNode(node) => node.children.get(0),
GameNode::MoveNode(node) => node.children.first(),
GameNode::SetupNode(node) => node.children.first(),
};
}