1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct UnfoldingStep {
7 source_face: usize,
8 target_face: usize,
9}
10
11impl UnfoldingStep {
12 #[must_use]
14 pub const fn new(source_face: usize, target_face: usize) -> Self {
15 Self {
16 source_face,
17 target_face,
18 }
19 }
20
21 #[must_use]
23 pub const fn faces(self) -> (usize, usize) {
24 (self.source_face, self.target_face)
25 }
26}
27
28#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct UnfoldingPlan {
31 steps: Vec<UnfoldingStep>,
32}
33
34impl UnfoldingPlan {
35 #[must_use]
37 pub const fn new(steps: Vec<UnfoldingStep>) -> Self {
38 Self { steps }
39 }
40
41 #[must_use]
43 pub fn steps(&self) -> &[UnfoldingStep] {
44 &self.steps
45 }
46
47 #[must_use]
49 pub fn step_count(&self) -> usize {
50 self.steps.len()
51 }
52}
53
54#[cfg(test)]
55mod tests {
56 use super::{UnfoldingPlan, UnfoldingStep};
57
58 #[test]
59 fn stores_unfolding_plans() {
60 let step = UnfoldingStep::new(0, 1);
61 let plan = UnfoldingPlan::new(vec![step]);
62
63 assert_eq!(step.faces(), (0, 1));
64 assert_eq!(plan.step_count(), 1);
65 assert_eq!(plan.steps(), &[step]);
66 }
67}