cube-rust 0.4.0

A efficient Rubik's Cube solver library
docs.rs failed to build cube-rust-0.4.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: cube-rust-0.5.1

cube-rust

Crates.io Documentation License GitHub

A high-performance, memory-safe Rust FFI wrapper for a C++ Rubik's Cube solver engine (Two-Phase Algorithm).

🚀 Features

  • Idiomatic API Design: Supports both functional chaining for immutable transformations and efficient in-place mutation.
  • Rich Error Diagnostics: CubeError fully implements std::error::Error and Display, accurately exposing underlying C++ engine diagnostic messages.
  • Batteries Included: Zero manual C++ configuration required. Automatically compiles C++17 source code and handles static linking via cc build script.

📦 Installation

Add cube-rust to your project using cargo:

cargo add cube-rust

Or add it manually to Cargo.toml:

[dependencies]
cube-rust = "0.3.1"

💡 Quick Start

use cube_rust::{Cube, CubeError};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 1. Initialize a cube in standard solved state
    let cube = Cube::default();

    // 2. Apply moves 
    cube.apply_maneuver_mut("R U F' D2").unwrap();

    // 3. Check if the scrambled state is solvable
    assert!(cube.is_solvable());

    // 4. Solve the cube safely
    match cube.solve() {
        Ok(solution) => println!("Solution: {solution}"),
        Err(err) => eprintln!("Failed to solve: {err}"),
    }

    Ok(())
}