formatting

This commit is contained in:
Michael Peters 2024-03-12 16:11:50 -07:00
parent 15a42ef20c
commit 08fd126255

View File

@ -38,7 +38,6 @@ struct Face {
br: Color,
}
#[allow(dead_code)]
impl Face {
fn new(c: Color) -> Self {
Self {
@ -167,32 +166,6 @@ fn parse_moves(moves_str: &str) -> Result<Vec<Move>, &'static str> {
Ok(moves)
}
#[rustfmt::skip]
fn apply_moves(c: &mut Cube, moves: Vec<Move>) {
for m in moves {
match m {
Move::U => { c.u(); },
Move::U2 => { c.u(); c.u(); },
Move::Up => { c.u(); c.u(); c.u(); },
Move::D => { c.d(); },
Move::D2 => { c.d(); c.d(); },
Move::Dp => { c.d(); c.d(); c.d(); },
Move::L => { c.l(); },
Move::L2 => { c.l(); c.l(); },
Move::Lp => { c.l(); c.l(); c.l(); },
Move::R => { c.r(); },
Move::R2 => { c.r(); c.r(); }
Move::Rp => { c.r(); c.r(); c.r(); }
Move::F => { c.f(); },
Move::F2 => { c.f(); c.f(); }
Move::Fp => { c.f(); c.f(); c.f(); }
Move::B => { c.b(); },
Move::B2 => { c.b(); c.b(); }
Move::Bp => { c.b(); c.b(); c.b(); }
}
}
}
struct Cube {
u: Face,
d: Face,
@ -220,7 +193,6 @@ impl fmt::Display for Cube {
}
}
#[allow(dead_code)]
impl Cube {
fn new() -> Self {
Self {
@ -293,6 +265,32 @@ impl Cube {
// TODO: efficient double / counter-clockwise
}
#[rustfmt::skip]
fn apply_moves(c: &mut Cube, moves: Vec<Move>) {
for m in moves {
match m {
Move::U => { c.u(); },
Move::U2 => { c.u(); c.u(); },
Move::Up => { c.u(); c.u(); c.u(); },
Move::D => { c.d(); },
Move::D2 => { c.d(); c.d(); },
Move::Dp => { c.d(); c.d(); c.d(); },
Move::L => { c.l(); },
Move::L2 => { c.l(); c.l(); },
Move::Lp => { c.l(); c.l(); c.l(); },
Move::R => { c.r(); },
Move::R2 => { c.r(); c.r(); }
Move::Rp => { c.r(); c.r(); c.r(); }
Move::F => { c.f(); },
Move::F2 => { c.f(); c.f(); }
Move::Fp => { c.f(); c.f(); c.f(); }
Move::B => { c.b(); },
Move::B2 => { c.b(); c.b(); }
Move::Bp => { c.b(); c.b(); c.b(); }
}
}
}
fn main() {
let mut c = Cube::new();
println!("Here's the cube:\n{}", c);