rust-lang / rust-lang/rust-bindgen

Better support for well-known C++ types

Open
#738 7 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Certain types like std::string or std::vector are quite common in C++ code, yet trying to run them through bindgen tends to be a nightmare because their implementations are actually very complicated. There are also types like string_view or llvm::StringRef that are conceptually identical to native Rust types (&str, in this case, sidestepping the issue of UTF-8/non-UTF-8) that would be useful to have represented as the native Rust type in function calls.

Rather than trying to work towards getting all the functionality necessary to build std::string (which is really a complex template that no one uses as such), it makes sense to provide a dedicated mapping mechanism specifically for the std::string type. This could perhaps be done by giving a mechanism to say "where you see type T as a function parameter in C/C++, use RustTy instead for the Rust code" and providing code to map between the C++ and Rust types.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by locating existing C++ type handling and type-mapping code in the repository; done would require a defined mechanism for mapping well-known C++ types to native Rust types, along with agreed behavior for conversions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
backend-api-design, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.