Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

crubit

> 编程语言
Open source

A bidirectional bindings generator for C++ and Rust.

1.1K stars0 likes1 views
WebsiteGitHub

About

A bidirectional bindings generator for C++ and Rust.

Crubit: C++/Rust Bidirectional Interop Tool

Crubit is a bidirectional bindings generator for C++ and Rust, with the goal of integrating the C++ and Rust ecosystems.

Status

See the status page for an overview of the current supported features.

Example

{{#tabs}}

{{#tab name="Calling Rust from C++"}}

Consider the following Rust library:

rust
pub struct Account {
    pub id: u64,
    pub balance: f64,
}

impl std::fmt::Display for Account { ... }

// Takes shared references, mapped to const references in C++.
pub fn calculate_interest(account: &Account, rate: f64) -> f64 { ... }

// Takes a string slice, mapped to rs_std::StrRef in C++.
pub fn is_valid_username(username: &str) -> bool { ... }

You can call these Rust functions from C++:

cpp
#include "path/to/account.h"
#include 

void demo() {
  account::Account my_account{.id = 123, .balance = 1000.0};
  double interest = account::calculate_interest(my_account, 0.05);

  // my_account is printable because Account implements Display in Rust!
  std::cout 
#include 
#include 

struct User {
  int id;
  double balance;
};

std::optional FindUser(int id);
std::unique_ptr CreateUser(std::string_view name, int id);

You can call these C++ functions from Rust:

rust
use cpp_std::unique_ptr;
use ffi_11::{c_double, c_int};
use user_api::{CreateUser, FindUser, User};

let id: c_int = 123;
let user: Option = FindUser(id);
if let Some(u) = user {
    let balance: c_double = u.balance;
    println!("User {} has balance {}", u.id, balance);
}

let new_user: unique_ptr = CreateUser("Alice".into(), 456);

{{#endtab}}

{{#endtabs}}

Getting Started

We have detailed walkthroughs on how to use C++ from Rust, or Rust from C++, using Crubit, as well as copy-pastable example code. The example code also includes spanshots of what the generated bindings look like.

  • Walkthrough: C++ Bindings for Rust Libraries
    • Examples: examples/rust/
  • Walkthrough: Rust Bindings for C++ Libraries
    • Examples: examples/cpp/

Test Matrix

Nightly Stable

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言