← All install guides

03 / RUST INSTALL

Build the Rust
bindings.

CoolBox includes a Rust library crate with neural-network, graphics, classical machine-learning, and data-structure APIs. Install Rust and a compatible C++ build toolchain, then build the native library and add the crate to your project.

10 MINRUST + C++INTERMEDIATE
What the Rust crate includes

The crate covers much of the Go binding surface, including deep learning and line, bar, and scatter plots. It does not provide full Python API parity; PCA/SVD/UMAP remain outside its documented coverage. It is a library crate, not a command-line executable, so cargo install is not the right command; its native C binding library must also be built.

Quick local setup

There is no one-command cargo install for this library. For a quick local build, clone CoolBox and build the native library before compiling the Rust crate:

TERMINAL · QUICK START
git clone --recurse-submodules https://github.com/MeanderingAI/CoolBox.git
cd CoolBox
cmake -S _deliverables/libraries/bindings/c_bindings -B _deliverables/libraries/bindings/c_bindings/build -DCMAKE_BUILD_TYPE=Release
cmake --build _deliverables/libraries/bindings/c_bindings/build --config Release
cd _deliverables/libraries/bindings/rust_bindings
cargo build --release

To use the crate from another Rust project on the same machine, add its local path in that project's Cargo.toml after the native build:

CARGO.TOML
[dependencies]
coolbox-rs = { path = "../CoolBox/_deliverables/libraries/bindings/rust_bindings" }

Adjust the relative path to where you cloned CoolBox. The crate's build script links to the C binding library built in the cloned repository, so adding the dependency alone does not replace the native build step.

Before you begin

Install Git, CMake, a C++17-capable compiler, and Rust with Cargo. Follow the official Rust installation guide ; on Windows, use the supported MSVC toolchain. Verify the Rust tools are available:

TERMINAL
rustc --version
cargo --version
cmake --version

1. Clone CoolBox

Clone the repository with its tracked submodules so the native sources are present:

TERMINAL
git clone --recurse-submodules https://github.com/MeanderingAI/CoolBox.git
cd CoolBox

2. Build the C++ binding library

From the repository root, configure and build the C bindings that the Rust crate wraps:

TERMINAL · REPOSITORY ROOT
cmake -S _deliverables/libraries/bindings/c_bindings -B _deliverables/libraries/bindings/c_bindings/build -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release
cmake --build _deliverables/libraries/bindings/c_bindings/build --config Release

3. Build and test the Rust crate

Change to the crate directory, compile the release library, and run its tests:

TERMINAL · REPOSITORY ROOT
cd _deliverables/libraries/bindings/rust_bindings
cargo build --release
cargo test

The build script links the Rust wrapper against the C++/C binding artifacts. If linking fails, check the CMake build output and the native library search paths for your platform.

Try the documented API

The crate README shows fitting a linear regression model and using it to predict values:

RUST
use coolbox_rs::{FitMethod, LinearRegression};

fn main() -> Result<(), String> {
    let x = vec![vec![1.0], vec![2.0], vec![3.0], vec![4.0]];
    let y = vec![3.0, 5.0, 7.0, 9.0];

    let model = LinearRegression::fit(
        &x,
        &y,
        FitMethod::ClosedForm,
        500,
        0.01,
    )?;
    println!("predictions = {:?}", model.predict(&x)?);
    Ok(())
}

See the repository’s Rust binding source and README for current API and build details.