pinned: bool,
moveable: PieceMoveable,
zlevel: ZLevel,
+ zupd: ZUSD,
}
#[derive(Debug,Clone,Default)]
tera: tera::Tera,
}
-#[derive(Debug,Clone)]
+#[derive(Debug,Clone,EnumDiscriminants)]
+#[strum_discriminants(derive(Ord,PartialOrd,Serialize))]
pub enum ZUpdateSpec {
Auto,
Spec(ZLevel),
GOnly,
}
use ZUpdateSpec as ZUS;
+use ZUpdateSpecDiscriminants as ZUSD;
+
+#[ext(pub)]
+impl ZUSD {
+ fn show(&self) -> char {
+ match self {
+ ZUSD::Auto => ' ',
+ ZUSD::Spec => '!',
+ ZUSD::GOnly => 'g',
+ }
+ }
+}
impl ZUpdateSpec {
pub fn next(self, last: &mut zcoord::Mutable, lastg: &mut Generation)
target: bool,
heavy: bool,
updated: bool,
+ zupd: ZUSD,
}
let coll = self.pieces.iter().map(|(&id, start)| {
id, new_z, old_z, updated,
heavy: start.heavy(),
target: self.targets.contains(&id),
+ zupd: start.zupd.into(),
}
}).collect_vec();
let new = sorted(&|p: &PieceCollated| p.new_z);
for (o, n) in izip!(&old, &new).rev() {
let pr = |p: &PieceCollated, zl: &ZLevel| {
- print!(" {:6} {}{}{} {}",
+ print!(" {:6} {}{}{} {} {}",
p.id.to_string(),
if p.target { "T" } else { "_" },
if p.heavy { "H" } else { "_" },
if p.updated { "U" } else { "_" },
+ p.zupd.show(),
zl.show());
};
pr(o, &o.old_z); print!(" ");
let pieces: IndexMap<Vpid,StartPiece> = pieces.into_iter().map(
|StartPieceSpec { id, pinned, moveable, zupd }| {
+ let zupd_d = (&zupd).into();
let id = id.try_into().unwrap();
let zlevel = zupd.next(&mut zlast, &mut zlastg);
- (id, StartPiece { pinned, moveable, zlevel })
+ (id, StartPiece { pinned, moveable, zlevel, zupd: zupd_d })
}
).collect();
println!("-------------------- {} --------------------", name);
for (id,p) in pieces.iter().rev() {
- println!(" {:6} {}{} {}",
+ println!(" {:6} {}{} {} {}",
id.to_string(),
if targets.contains(id) { "T" } else { "_" },
if p.heavy() { "H" } else { "_" },
+ p.zupd.show(),
p.zlevel.show());
}
pub use serde_with::SerializeDisplay;
pub use sha2::{Sha512, Sha512Trunc256};
pub use slotmap::{dense::DenseSlotMap, SparseSecondaryMap, Key as _};
-pub use strum::{EnumCount};
+pub use strum::{EnumCount, EnumDiscriminants};
pub use strum::{EnumString, EnumIter, EnumMessage, EnumProperty};
pub use strum::{IntoEnumIterator, IntoStaticStr};
pub use subtle::ConstantTimeEq;