bazel /
crubit /
184f9ace5ac3a977ce74d5ceb0f913bb3e32e60f Add const.
Note the distinction here between Rust-level constness and C++-level constness: in Rust, const is a property of pointers. In C++, it's a property of types.
And so for example:
| C++ | Rust |
|------------------------------|--------------------------|
| `const T ` | `T` |
| `const T*` (aka `T const *`) | `*const T` |
| `U<const T>` | who knows? Depends on U. |
We preserve the `const` bit in the IR for C++ codegen, even though it has no impact on the Rust after the rust type is determined.
Similarly, in the future, `volatile` is even worse than `const`: it isn't a property of objects, or of pointers, but of **individual accesses**. This is the correct model, but makes it even less like C++.
---
Extra notes:
There are two types for which cv-qualification does not apply: references and functions. So strictly speaking, much as the current structure allows for you to make a nonsensical `* <T, U>` or `*<>`, it also allows for a nonsensical cv-qualified reference type of function type (when we add those). Something to keep in mind if we tighten up the type struct.
PiperOrigin-RevId: 397308355
6 files changed
tree: 0b84b41f1280f0943598e5ff367ebcece7b2af37
- rs_bindings_from_cc/
- CODE_OF_CONDUCT
- CONTRIBUTING
- LICENSE
- README.md
README.md
Crubit: C++/Rust Bidirectional Interop Tool
Extremely experimental interop tooling for C++ and Rust.
Please don‘t use, this is an experiment and we don’t yet know where will it take us. There will be breaking changes without warning. Unfortunately, we can't take contributions at this point.