tree: c86f057815172dfddbc4d5d996eec2ddecded8a2 [search]
  1. BUILD
  2. README.md
support/cc_std/README.md

Rust bindings for the C++ standard library

This directory contains the cc_std Rust crate - the crate generated by rust_api_from_cpp and providing bindings for the C++ standard library.

To use C++ standard library types from Rust, depend on the cpp_std support library in your deps:

deps = ["//support:cpp_std"]

and use types via cpp_std::{sometype} (e.g. cpp_std::unique_ptr<T>).

Alternatively, the legacy cc_std crate can be added via cc_deps:

deps = ["//support/public:cc_std"]

This crate provides, for example:

  • The cc_std::std::raw_string_view type alias (corresponding to std::string_view in C++)
  • The cc_std::tm struct (corresponding to tm in C++)

In addition to automatically generated bindings, the crate also provides manually authored trait implementations that supplement the automated bindings. For example:

  • impl From<&'static str> for raw_string_view

Versioning

The source code for cc_std is a combination of the automatically generated bindings for the C++ standard library, and auxiliary Rust code which is live-at-head, and lives in the a parallel cc_std_impl directory.

cc_std can be snapshotted and released as part of a release process. Backwards-incompatible changes which must go out with a release can be implemented as feature flags, but the actual source code is always read at head.