Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/cpp/operator_overloading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename Sink> void AbslStringify(Sink&, const T&)`
* `template <typename Sink> 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 }}
```
<!-- symbol:CRUBIT_OVERRIDE_DISPLAY -->