From d923173e725aa1a87526d2f6cafad093b39ef2ae Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 19 Mar 2026 08:54:37 -0700 Subject: [PATCH] Document Crubit's mapping from C++ to Rust `Display`. PiperOrigin-RevId: 886205830 --- docs/cpp/operator_overloading.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/cpp/operator_overloading.md b/docs/cpp/operator_overloading.md index 7a4f6818c..902a51f70 100644 --- a/docs/cpp/operator_overloading.md +++ b/docs/cpp/operator_overloading.md @@ -68,3 +68,26 @@ C++ API | Rust bindings ----------- | ------------- `operator-` | `Neg` `operator!` | `Not` + +## One-way map into `Display` + +By default: for a C++ type `T`, Crubit maps one-way the following C++ signatures +into the Rust trait `Display`: + +* `template void AbslStringify(Sink&, const T&)` +* `template void AbslStringify(Sink&, T)` +* `std::ostream& operator<<(std::ostream&, const T&)` +* `std::ostream& operator<<(std::ostream&, T)` + +Crubit prefers +[`AbslStringify`](https://abseil.io/docs/cpp/guides/abslstringify) but falls +back to `operator<<`. + +The [attribute macro](customizing.md) `CRUBIT_OVERRIDE_DISPLAY` forces whether +to implement the `Display` binding. See the macro's documentation: + +``` +{{ #include ../../support/annotations.h }} +``` + +