NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io, #1077 most downloaded on crates.io
Safe interop between Rust and C++
Latest stable
1.0.205
Last release 1 months ago
11 Oct 2026
Ships unpredictably
gaps range from 8 days to 5 months
Nearly every release is documented
notes for 59 of the last 60 stable releases
4 versions withdrawn
withdrawn after publishing
7 years old
252 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
Apply symbol visibility attributes to instantiations of Rust generic shims
allow, warn, deny, forbid) inside of bridge module (#620)Handle .hh and .hpp header extensions equivalently to .h (#613, #614, thanks @permosegaard)
.hh and .hpp header extensions equivalently to .h (#613, #614, thanks @permosegaard)Add cxx::WeakPtr , a binding of C++'s std::weak_ptr
Your coding agent can read these notes before it upgrades. Set up the MCP server →
cxx::WeakPtr<T>, a binding of C++'s std::weak_ptr<T> (#609)Add accessors for the size and alignment of an opaque Rust type
Add accessors for the size and alignment of an opaque Rust type (#597)
namespace rust {
+ template <typename T> size_t size_of();
+ template <typename T> size_t align_of();
}
Expand API of rust::Slice<T> in C++ (#598)
template <typename T>
class Slice {
public:
...
+ bool empty() const noexcept;
+ T &operator[](size_t n) const noexcept;
+ T &at(size_t n) const;
+ T &front() const noexcept;
+ T &back() const noexcept;
};
Expand rust::Slice<T>::iterator from a forward-only iterator to random access iterator (#599)
Support using rust::Slice<T> with T an opaque Rust type, previously limited to shared types only (#600, #601, #602, #603)
Support cxx_name/rust_name attributes on enum variants
cxx_name/rust_name attributes on enum variants (#379)get_mut, get_unchecked_mut, iter_mut (#589, #591)Allow C++ types with a Trivial ExternType impl to be passed unpinned by mutable reference (#550, thanks @adetaylor)
Ensure CxxVector's iterator type implements ExactSizeIterator and FusedIterator (#581, #582)
CxxVector's iterator type implements ExactSizeIterator and FusedIterator (#581, #582)self argument as allowing a mutable reference in return position from C++ member function (#583)Fix exception safety of rust::Box\ ::in_place if T's constructor throws (#572, #574)
T's constructor throws (#572, #574)Restore compatibility with Visual C++ 14.0
Add Vec capacity accessor (#565) and copy constructor and copy assignment operator
template <typename T>
class Vec final {
...
+ Vec(const Vec &);
+ Vec &operator=(const Vec &);
+ size_t capacity() const noexcept;
};
Support shared_ptr of primitives, such as SharedPtr
SharedPtr<u32> (#562)Support Vec\ where T is a shared struct from a different bridge module
impl Vec<T> {} and impl Box<T> {} (#542, #555)std::hash template specialization via #[derive(Hash)] (#556, #557)operator new in the implementation of UniquePtr::new (#553)Fix a unique_ptr import in bridge modules that involve CxxVector but not UniquePtr
Support parsing empty value for namespace attribute
impl Debug for CxxVector<T> (#540)
Support parsing empty value for namespace attribute
#[cxx::bridge(namespace = "some::path")]
mod ffi {
#[namespace = ""]
struct InGlobalNamespace {...} // exposed at ::InGlobalNamespace
// everything else would be under ::some::path
}
Upgrade rust::Vec 's iterator category from "forward iterator" to "random access iterator" to allow sorting and other random iteration (#538, thanks @
rust::Vec<T>'s iterator category from "forward iterator" to "random access iterator" to allow sorting and other random iteration (#538, thanks @mindv0rtex)Add cxx::SharedPtr , a binding for C++ std::shared_ptr
cxx::SharedPtr<T>, a binding for C++ std::shared_ptr (#536)Support derive(PartialOrd, Ord) on shared enums
Support derive(PartialOrd, Ord) on shared enums
Add non-const indexing overloads for rust::Vec<T> in C++: https://cxx.rs/binding/vec.html
const T &operator[](size_t n) const noexcept;
const T &at(size_t n) const;
const T &front() const;
const T &back() const;
+ T &operator[](size_t n) noexcept;
+ T &at(size_t n);
+ T &front();
+ T &back();
Add comparison operators (==, !=, <, <=, >, >=) on rust::Str and rust::String
Add comparison operators (==, !=, <, <=, >, >=) on rust::Str and rust::String (#531)
Add a constructor for rust::Vec<T> taking a std::initializer_list<T> (#533)
rust::Vec<rust::String> vec = {"good", "stuff"};
Allow associated methods of the same name on different types in the same bridge
Connect standard library derives on shared types to C++ operator overloads (#518, #519, #520, #521, #522)
derive(PartialEq) on the Rust side turns into C++ operator== and operator!=derive(PartialOrd) turns into operator<, operator<=, operator>, operator>=derive(Hash) turns into a specialization of template <> struct std::hash<T>#[cxx::bridge]
mod ffi {
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
struct AllTheDerives {
x: i32,
y: i32,
}
}
// generated
struct AllTheDerives final {
int32_t x;
int32_t y;
bool operator==(const AllTheDerives &) const noexcept;
bool operator!=(const AllTheDerives &) const noexcept;
bool operator<(const AllTheDerives &) const noexcept;
bool operator<=(const AllTheDerives &) const noexcept;
bool operator>(const AllTheDerives &) const noexcept;
bool operator>=(const AllTheDerives &) const noexcept;
};
namespace std {
template <> struct hash<AllTheDerives> {
size_t operator()(const AllTheDerives &self) const noexcept;
};
}
Add mutable iterators for rust::Vec in C++
Add mutable iterators for rust::Vec<T> in C++ (#509)
class Vec<T> {
+ class iterator;
+ iterator begin() noexcept;
+ iterator end() noexcept;
class const_iterator;
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
};
Support slices with arbitrary element type (previously restricted to u8) (#514)
Add c_char type which refers to std::os::raw::c_char in Rust and char in C++ (#515)
Add iterator for rust::Slice<T> and rust::Slice<const T> (#516)
class Slice<T> {
+ class iterator;
+ iterator begin() const noexcept;
+ iterator end() const noexcept;
};
Add iterators for rust::String and rust::Str (#517)
class String {
+ using iterator = char *;
+ iterator begin() noexcept;
+ iterator end() noexcept;
+ using const_iterator = const char *;
+ const_iterator begin() const noexcept;
+ const_iterator end() const noexcept;
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
};
class Str {
+ using iterator = const char *;
+ using const_iterator = const char *;
+ const_iterator begin() const noexcept;
+ const_iterator end() const noexcept;
+ const_iterator cbegin() const noexcept;
+ const_iterator cend() const noexcept;
};
Implement translation between Rust [T; N] and C++ std::array
[T; N] and C++ std::array<T, N> (#503)Support &mut [u8] (spelled rust::Slice in C++) in extern function arguments and returns
&mut [u8] (spelled rust::Slice<uint8_t> in C++) in extern function arguments and returns (#502)Support shared enums without any explicitly declared variants as long as they are provided a defined repr
Support shared enums without any explicitly declared variants as long as they are provided a defined repr (#494)
#[cxx::bridge]
mod ffi {
#[repr(i32)]
enum SharedEnum {}
}
Fix ability to use an extern enum (https://cxx.rs/shared.html#extern-enums) as a field of a shared struct
extern "C" extern block in the FFI module is no longer accepted, write extern "C++" instead
extern "C" extern block in the FFI module is no longer accepted, write extern "C++" insteadextern "C++" block must be written unsafe extern "C++" if it contains at least one safe-to-call functionrust::Slice<T> in C++ has been renamed to rust::Slice<const T>; support for &mut [T] post-1.0 will use the rust::Slice<T> name&mut T where T is an opaque C++ type is no longer ever exposed to Rust, only Pin<&mut T>UniquePtr binding no longer implements DerefMut for opaque C++ typesextern "Rust" block will enforce that it's listed as unsafe fn in the extern block tooUnpin in addition to SizedUnpin impl for opaque C++ types are ruled outFix missing cstdint import when generating enums
Add the following member functions on rust::Vec in C++, matching the API of std::vector:
Add the following member functions on rust::Vec<T> in C++, matching the API of std::vector:
void reserve(size_t new_cap);
void push_back(const T &value);
void push_back(T &&value);
template <typename... Args>
void emplace_back(Args &&... args);
Support #[namespace = "..."] attribute on extern blocks
Support #[namespace = "..."] attribute on extern blocks (#444)
An item will inherit the namespace specified on its surrounding extern block if any, otherwise the namespace specified with the top level cxx::bridge attribute.
#[cxx::bridge(namespace = "third_priority")]
mod ffi {
#[namespace = "second_priority"]
extern "Rust" {
fn f();
#[namespace = "first_priority"]
fn g();
}
extern "Rust" {
fn h();
}
}
The above would result in functions ::second_priority::f, ::first_priority::g, ::third_priority::h.
Fix non-compilable C++ code generated when a no-argument method returns String
Support methods/member functions on shared structs
Introduce a mechanism to publicly export headers from a dependency in Cargo-based builds (#417) See the documentation of:
Fix no template named 'impl' error in modules containing a reference to &[u8] but no reference to Result
no template named 'impl' error in modules containing a reference to &[u8] but no reference to ResultAdd an item-level #[namespace = "..."] attribute to specify the C++ namespace path of an individual type or function (#370, #380, thanks @adetaylor)
Add an item-level #[namespace = "..."] attribute to specify the C++ namespace path of an individual type or function (#370, #380, thanks @adetaylor)
#[cxx::bridge]
mod ffi {
#[namespace = "the::path::of"]
struct Thing {...}
extern "C++" {
#[namespace = "some::where::else"]
fn function() -> Thing;
}
}
Emit diagnostic on include! paths relative to . or .., as the positioning of generated code inside of Cargo's OUT_DIR is not specified (#368, #375)
Treat C++ constructors rust::String(nullptr, 0) and rust::Str(nullptr, 0) as creating empty strings; previously UB (#383)
Enable rust::Str and rust::Slice<T> to be passed in registers by C++ (#387)
Eliminate warning from rustc 1.46+ when using function pointers in the signature of an extern C++ function (#396)
Support single Rust source file containing multiple #[cxx::bridge] modules (#397)
Expose a way to bypass is_trivially_destructible/_move_constructible check on extern types passed by value (#406)
// IsRelocatable<T> is used in assertions that a C++ type passed by value
// between Rust and C++ is soundly relocatable by Rust.
//
// There may be legitimate reasons to opt out of the check for support of types
// that the programmer knows are soundly Rust-movable despite not being
// recognized as such by the C++ type system due to a move constructor or
// destructor. To opt out of the relocatability check, do either of the
// following things in any header used by `include!` in the bridge.
//
// --- if you define the type:
// struct MyType {
// ...
// + using IsRelocatable = std::true_type;
// };
//
// --- otherwise:
// + template <>
// + struct rust::IsRelocatable<MyType> : std::true_type {};
template <typename T>
struct IsRelocatable;
Fix error on pass-by-reference of a shared struct containing a Rust String to a C++ function (#408)
Make shared structs order-independent such that a struct is able to contain a field whose type is another shared struct defined later in the same FFI module (#411)
Allow creation of UniquePtrs to extern type aliases of trivial extern types (#361, thanks @adetaylor)
Enable functions to have a different name between Rust and C++
#[cxx::bridge]
mod ffi {
extern "C++" {
include!("path/to/header.h");
#[cxx_name = "take"]
fn take_int(i: i32);
#[cxx_name = "take"] // different overload of the same name in C++
fn take_str(s: &str);
}
}
Enable extern type aliases to be passed and returned by value across the FFI as long as an unsafe impl ExternType impl claims that the underlying C++
unsafe impl ExternType impl claims that the underlying C++ type is trivially move constructible and trivially destructible; see https://docs.rs/cxx/0.5.0/cxx/trait.ExternType.html#associatedtype.Kind (#325, thanks @adetaylor)UniquePtr<MyType>, to be produced on demand (#336)Add CxxVector::as_slice to get a &\[T\] from a C++ vector
CxxVector::as_slice to get a &[T] from a C++ vector (#322)--header command line flag optional when outputting to a file ending with .h extension (#318)cxxbridge command line invocation outputting both the generated header and generated source file (#319)Fix noncompilable generated code when returning Result\ \> from Rust to C++ (#309, #311)
Add -o/--output flag for cxxbridge CLI to control output location
-o/--output flag for cxxbridge CLI to control output location (#299)Make rust::Error inherit publicly from std::exception so that it can be caught by catch (const std::exception &e) {
rust::Error inherit publicly from std::exception so that it can be caught by catch (const std::exception &e) {Support working with a C++ namespace that contains Rust reserved words in the namespace path
Fix missing definitions in generated code involving Vec
- as referring to stdin in the command line code generator (#278)Fix out-of-date generated code being pulled into Cargo builds
Breaking change: the default #include path set up for your build by cxx_build::bridge now contains the crate name as the first component of paths. So…
Fix various sources of brittleness in the Cargo-based workflow (#88, #213)
Breaking change: the default #include path set up for your build by cxx_build::bridge now contains the crate name as the first component of paths. So if your crate name is my-crate and cxx_build::bridge is invoked with "src/lib.rs" as the local path, the resulting generated header would be includable from C++ as #include "my-crate/src/lib.rs.h". Headers from dependencies are now also available exactly the same way: their crate name followed by local path within the crate.
Update documentation to reflect new path of demo crate in the repo
demo crate in the repoImprove reporting of i/o errors from C++ code generator
Support function signatures that involve Vec\ where T is an extern C-style enum
Add `cxx::String` and `cxx::Vector` type aliases
cxx::String and cxx::Vector type aliases (#265)Vec<String> and CxxVector<CxxString> (#153)Add rust::Str and rust::String constructors taking const char * + size_t
rust::Str and rust::String constructors taking const char * + size_t (#242)rust::Vec accessors: operator[], at, front, back (#257, thanks @rinon)no matching function for call to 'operator new' error (#238)#pragma once (#246)&mut Vec<T> (#263)Fix noncompilable C++ code generated for an extern C++ member function with no args and a Result return type (#210, thanks @myronahn)
Resolve enum repr based on repr attributes, discriminant suffixes, and discriminant values
Fix build error when using the nix version of clang (#192, thanks @cchalmers)
Support C-style enums (#170, #182, #187, thanks @jgalenson)
Divide Cargo-specific build-only dependencies out to a cxx-build crate, leaving the cxx crate containing only runtime components (#144, #167)
cxx-build crate, leaving the cxx crate containing only runtime components (#144, #167)Accept wildcard in extern function argument names (#159, thanks @jgalenson)
Support passing std::vector\ and Rust's Vec\ between languages (#67, #148, thanks @myronahn)
Associated method/member function support (#121, #131, thanks @jgalenson)
Support passing &\[u8\] byte slices (#117, thanks @adetaylor)
Support building with -fno-exceptions
One column per quarter.