cube-rust 0.5.0

A efficient Rubik's Cube solver library
Documentation
  • Coverage
  • 93.33%
    14 out of 15 items documented1 out of 14 items with examples
  • Size
  • Source code size: 83.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 408.7 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 31s Average build duration of successful builds.
  • all releases: 33s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • coshz/cube
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • coshz

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.5.0"

💡 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(())
}