src/cube.rs

changeset 11
933242e0f3b8
parent 10
cd6f6e7defd2
child 12
3b05a8b45b95
--- a/src/cube.rs	Mon Oct 21 15:07:41 2024 -0500
+++ b/src/cube.rs	Mon Oct 21 23:07:01 2024 -0500
@@ -52,8 +52,26 @@
     }
 }
 
+impl std::fmt::Display for Face {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        let s = match *self {
+            F1 => "F1",
+            F2 => "F2",
+            F3 => "F3",
+            F4 => "F4",
+            F5 => "F5",
+            F6 => "F6",
+        };
+        write!(f, "{}", s)
+    }
+}
 
 impl Face {
+    /// Return an aray of all faces
+    pub fn all() -> [Face; 6] {
+        [F1, F2, F3, F4, F5, F6]
+    }
+
     /// Returns an array of the four faces adjacent to `self` in the
     /// order [left, right, down, up] in the `self`-relative unfolding.
     pub fn adjacent_faces(&self) -> AdjacentFaces {

mercurial