Skip to content

Commit

Permalink
[search.rs] impl<'a> From<SolutionMoves<'a>> for Alg
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Oct 5, 2023
1 parent 7b72198 commit 284aebc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/rs/search/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@ struct SolutionPreviousMoves<'a> {

struct SolutionMoves<'a>(Option<&'a SolutionPreviousMoves<'a>>);

impl<'a> SolutionMoves<'a> {
pub fn get_alg(&self) -> Alg {
let nodes = self.get_alg_nodes();
impl<'a> From<SolutionMoves<'a>> for Alg {
fn from(value: SolutionMoves<'a>) -> Self {
let nodes = value.get_alg_nodes();
Alg { nodes }
}
}

impl<'a> SolutionMoves<'a> {
fn get_alg_nodes(&self) -> Vec<AlgNode> {
match self.0 {
Some(solution_previous_moves) => {
Expand Down Expand Up @@ -232,7 +234,7 @@ impl IDFSearch {
individual_search_data.current_depth_num_recursive_calls += 1;
if remaining_depth == 0 {
return if current_pattern == &self.target_pattern {
println!("Found a solution: {}", solution_moves.get_alg());
println!("Found a solution: {}", Alg::from(solution_moves));
SearchRecursionResult::SolutionFound(Alg { nodes: vec![] })
} else {
SearchRecursionResult::SolutionNotFoundDefault()
Expand Down

0 comments on commit 284aebc

Please sign in to comment.