Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 608a650

Browse files
committed
Update guidance about use of the Result type
1 parent 85eb27c commit 608a650

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

docs/development/contributing.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ Additionally, please follow these guidelines:
6565
* Keep the Rust code to the leaves.
6666
* Don't hand over control between Rust and C++ more than absolutely necessary.
6767
* Have C++ call into Rust, not the other way around.
68-
* Don't use cxx to return `Result` types across the FFI. (It might throw a C++
69-
exception.)
70-
* Run `cargo fix && cargo fmt` before submitting code for review. You may need to run the
71-
nightly to support all options in `rustfmt.toml`: `rustup run nightly cargo
72-
fmt`.
68+
* Use of `Result` types across the FFI is permitted, because it is the only enum
69+
(variant) type Cxx supports and the only good way to indicate failures. If you
70+
do return `Result`, **you MUST wrap the C++ call site in a `try-catch`
71+
block.**
72+
* Run `cargo fix && cargo fmt` before submitting code for review. You may need
73+
to run the nightly to support all options in `rustfmt.toml`: `rustup run
74+
nightly cargo fmt`.
7375

7476
### The small print
7577
Contributions made by corporations are covered by a different agreement than

0 commit comments

Comments
 (0)