pub fn as_pieces(&self) -> Cube3x3x3 {
        let mut pieces = Cube3x3x3::new();

        for corner_idx in 0..8 {
            let corner_colors: [Color; 3] = [
                self.corner_color(Corner::try_from(corner_idx).unwrap(), 0),
                self.corner_color(Corner::try_from(corner_idx).unwrap(), 1),
                self.corner_color(Corner::try_from(corner_idx).unwrap(), 2),
            ];
            // Find this corner piece and orientation
            for i in 0..8 {
                if corner_colors[0] == crate::tables::corner::CUBE_CORNER_COLORS[i][0]
                    && corner_colors[1] == crate::tables::corner::CUBE_CORNER_COLORS[i][1]
                    && corner_colors[2] == crate::tables::corner::CUBE_CORNER_COLORS[i][2]
                {
                    pieces.corners[corner_idx as usize] = CornerPiece {
                        piece: Corner::try_from(i as u8).unwrap(),
                        orientation: 0,
                    };
                    break;
                } else if corner_colors[1] == crate::tables::corner::CUBE_CORNER_COLORS[i][0]
                    && corner_colors[2] == crate::tables::corner::CUBE_CORNER_COLORS[i][1]
                    && corner_colors[0] == crate::tables::corner::CUBE_CORNER_COLORS[i][2]
                {
                    pieces.corners[corner_idx as usize] = CornerPiece {
                        piece: Corner::try_from(i as u8).unwrap(),
                        orientation: 1,
                    };
                    break;
                } else if corner_colors[2] == crate::tables::corner::CUBE_CORNER_COLORS[i][0]
                    && corner_colors[0] == crate::tables::corner::CUBE_CORNER_COLORS[i][1]
                    && corner_colors[1] == crate::tables::corner::CUBE_CORNER_COLORS[i][2]
                {
                    pieces.corners[corner_idx as usize] = CornerPiece {
                        piece: Corner::try_from(i as u8).unwrap(),
                        orientation: 2,
                    };
                    break;
                }
            }
        }

        for edge_idx in 0..12 {
            let edge_colors: [Color; 2] = [
                self.edge_color(Edge3x3x3::try_from(edge_idx).unwrap(), 0),
                self.edge_color(Edge3x3x3::try_from(edge_idx).unwrap(), 1),
            ];
            // Find this edge piece and orientation
            for i in 0..12 {
                if edge_colors[0] == crate::tables::table3x3x3::CUBE3_EDGE_COLORS[i][0]
                    && edge_colors[1] == crate::tables::table3x3x3::CUBE3_EDGE_COLORS[i][1]
                {
                    pieces.edges[edge_idx as usize] = EdgePiece3x3x3 {
                        piece: Edge3x3x3::try_from(i as u8).unwrap(),
                        orientation: 0,
                    };
                    break;
                } else if edge_colors[1] == crate::tables::table3x3x3::CUBE3_EDGE_COLORS[i][0]
                    && edge_colors[0] == crate::tables::table3x3x3::CUBE3_EDGE_COLORS[i][1]
                {
                    pieces.edges[edge_idx as usize] = EdgePiece3x3x3 {
                        piece: Edge3x3x3::try_from(i as u8).unwrap(),
                        orientation: 1,
                    };
                    break;
                }
            }
        }

        pieces
    }
/// Gets this cube state in piece format
Gets this cube state in piece format
Gets this cube state in piece format
pub fn as_pieces(&self) -> Cube3x3x3 {
        let mut pieces = Cube3x3x3::new();
        for corner_idx in 0..8 {
            let corner_colors: [Color; 3] = [
                self.corner_color(Corner::try_from(corner_idx).unwrap(), 0),
                self.corner_color(Corner::try_from(corner_idx).unwrap(), 1),
                self.corner_color(Corner::try_from(corner_idx).unwrap(), 2),
            ];
            // Find this corner piece and orientation
            for i in 0..8 {
                if corner_colors[0] == crate::tables::corner::CUBE_CORNER_COLORS[i][0]
                    && corner_colors[1] == crate::tables::corner::CUBE_CORNER_COLORS[i][1]
                    && corner_colors[2] == crate::tables::corner::CUBE_CORNER_COLORS[i][2]
                {
                    pieces.corners[corner_idx as usize] = CornerPiece {
                        piece: Corner::try_from(i as u8).unwrap(),
                        orientation: 0,
                    };
                    break;
                } else if corner_colors[1] == crate::tables::corner::CUBE_CORNER_COLORS[i][0]
                    && corner_colors[2] == crate::tables::corner::CUBE_CORNER_COLORS[i][1]
                    && corner_colors[0] == crate::tables::corner::CUBE_CORNER_COLORS[i][2]
                {
                    pieces.corners[corner_idx as usize] = CornerPiece {
                        piece: Corner::try_from(i as u8).unwrap(),
                        orientation: 1,
                    };
                    break;
                } else if corner_colors[2] == crate::tables::corner::CUBE_CORNER_COLORS[i][0]
                    && corner_colors[0] == crate::tables::corner::CUBE_CORNER_COLORS[i][1]
                    && corner_colors[1] == crate::tables::corner::CUBE_CORNER_COLORS[i][2]
                {
                    pieces.corners[corner_idx as usize] = CornerPiece {
                        piece: Corner::try_from(i as u8).unwrap(),
                        orientation: 2,
                    };
                    break;
                }
            }
        }
        for edge_idx in 0..12 {
            let edge_colors: [Color; 2] = [
                self.edge_color(Edge3x3x3::try_from(edge_idx).unwrap(), 0),
                self.edge_color(Edge3x3x3::try_from(edge_idx).unwrap(), 1),
            ];
            // Find this edge piece and orientation
            for i in 0..12 {
                if edge_colors[0] == crate::tables::table3x3x3::CUBE3_EDGE_COLORS[i][0]
                    && edge_colors[1] == crate::tables::table3x3x3::CUBE3_EDGE_COLORS[i][1]
                {
                    pieces.edges[edge_idx as usize] = EdgePiece3x3x3 {
                        piece: Edge3x3x3::try_from(i as u8).unwrap(),
                        orientation: 0,
                    };
                    break;
                } else if edge_colors[1] == crate::tables::table3x3x3::CUBE3_EDGE_COLORS[i][0]
                    && edge_colors[0] == crate::tables::table3x3x3::CUBE3_EDGE_COLORS[i][1]
                {
                    pieces.edges[edge_idx as usize] = EdgePiece3x3x3 {
                        piece: Edge3x3x3::try_from(i as u8).unwrap(),
                        orientation: 1,
                    };
                    break;
                }
            }
        }
        pieces
    }
pub fn as_pieces ( & self ) -> Cube3x3x3 { let mut pieces = Cube3x3x3 :: new ( ) ; for corner_idx in 0 .. 8 { let corner_colors : [ Color ; 3 ] = [ self . corner_color ( Corner :: try_from ( corner_idx ) . unwrap ( ) , 0 ) , self . corner_color ( Corner :: try_from ( corner_idx ) . unwrap ( ) , 1 ) , self . corner_color ( Corner :: try_from ( corner_idx ) . unwrap ( ) , 2 ) , ] ; // Find this corner piece and orientation for i in 0 .. 8 { if corner_colors [ 0 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 0 ] && corner_colors [ 1 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 1 ] && corner_colors [ 2 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 2 ] { pieces . corners [ corner_idx as usize ] = CornerPiece { piece : Corner :: try_from ( i as u8 ) . unwrap ( ) , orientation : 0 , } ; break ; } else if corner_colors [ 1 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 0 ] && corner_colors [ 2 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 1 ] && corner_colors [ 0 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 2 ] { pieces . corners [ corner_idx as usize ] = CornerPiece { piece : Corner :: try_from ( i as u8 ) . unwrap ( ) , orientation : 1 , } ; break ; } else if corner_colors [ 2 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 0 ] && corner_colors [ 0 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 1 ] && corner_colors [ 1 ] == crate :: tables :: corner :: CUBE_CORNER_COLORS [ i ] [ 2 ] { pieces . corners [ corner_idx as usize ] = CornerPiece { piece : Corner :: try_from ( i as u8 ) . unwrap ( ) , orientation : 2 , } ; break ; } } } for edge_idx in 0 .. 12 { let edge_colors : [ Color ; 2 ] = [ self . edge_color ( Edge3x3x3 :: try_from ( edge_idx ) . unwrap ( ) , 0 ) , self . edge_color ( Edge3x3x3 :: try_from ( edge_idx ) . unwrap ( ) , 1 ) , ] ; // Find this edge piece and orientation for i in 0 .. 12 { if edge_colors [ 0 ] == crate :: tables :: table3x3x3 :: CUBE3_EDGE_COLORS [ i ] [ 0 ] && edge_colors [ 1 ] == crate :: tables :: table3x3x3 :: CUBE3_EDGE_COLORS [ i ] [ 1 ] { pieces . edges [ edge_idx as usize ] = EdgePiece3x3x3 { piece : Edge3x3x3 :: try_from ( i as u8 ) . unwrap ( ) , orientation : 0 , } ; break ; } else if edge_colors [ 1 ] == crate :: tables :: table3x3x3 :: CUBE3_EDGE_COLORS [ i ] [ 0 ] && edge_colors [ 0 ] == crate :: tables :: table3x3x3 :: CUBE3_EDGE_COLORS [ i ] [ 1 ] { pieces . edges [ edge_idx as usize ] = EdgePiece3x3x3 { piece : Edge3x3x3 :: try_from ( i as u8 ) . unwrap ( ) , orientation : 1 , } ; break ; } } } pieces }
Gets this cube state in piece format
Gets this cube state in piece format
&self
&self