Implement Debug for intermediate puzzle search state.
This commit is contained in:
parent
6689b0106f
commit
b1b727b38e
@ -2,6 +2,7 @@
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::collections::BTreeSet;
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
use std::mem;
|
||||
use std::ops::Index;
|
||||
@ -695,6 +696,28 @@ impl<'a> PuzzleSearch<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> fmt::Debug for PuzzleSearch<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
write!(f, "PuzzleSearch={{")?;
|
||||
for (idx, var) in self.vars.iter().enumerate() {
|
||||
writeln!(f, "")?;
|
||||
match var {
|
||||
&VarState::Assigned(val) => {
|
||||
write!(f, " var {}: {}", idx, val)?;
|
||||
},
|
||||
&VarState::Unassigned(ref cs) => {
|
||||
write!(f, " var {}:", idx)?;
|
||||
for val in cs.iter() {
|
||||
write!(f, " {}", val)?;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
write!(f, "}}")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Index<VarToken> for PuzzleSearch<'a> {
|
||||
type Output = Val;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user