mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-01-17 12:00:27 +02:00
Chromium exercise solutions (#1564)
The main thing in this CL is a link to exercise solutions but there are a couple of other very minor tweaks.
This commit is contained in:
parent
97b18e8538
commit
cc8405d04f
@ -278,6 +278,7 @@
|
||||
- [Keeping crates up to date](chromium/adding-third-party-crates/keeping-up-to-date.md)
|
||||
- [Exercise](exercises/chromium/third-party.md)
|
||||
- [Bringing it together - Exercise](exercises/chromium/bringing-it-together.md)
|
||||
- [Exercise Solutions](exercises/chromium/solutions.md)
|
||||
|
||||
|
||||
# Bare Metal: Morning
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Example bindings
|
||||
|
||||
CXX requires that the whole C++/Rust boundary is declared in `cxx::bridge`
|
||||
"modules" inside `.rs` source code.
|
||||
modules inside `.rs` source code.
|
||||
|
||||
```rust,ignore
|
||||
{{#include ../../../third_party/cxx/book/snippets.rs:cxx_overview}}
|
||||
@ -11,6 +11,10 @@ CXX requires that the whole C++/Rust boundary is declared in `cxx::bridge`
|
||||
|
||||
Point out:
|
||||
|
||||
* Although this looks like a regular Rust `mod`, the `#[cxx::bridge]`
|
||||
procedural macro does complex things to it. The generated code is quite
|
||||
a bit more sophisticated - though this does still result in a `mod` called
|
||||
`ffi` in your code.
|
||||
* Native support for C++'s `std::unique_ptr` in Rust
|
||||
* Native support for Rust slices in C++
|
||||
* Calls from C++ to Rust, and Rust types (in the top part)
|
||||
|
@ -33,7 +33,7 @@ compromise the safety of Rust's own data layouts. Presence of _too many_
|
||||
such a keyword, and is [controversial][1], but strictly, bringing any foreign
|
||||
code into a Rust binary can cause unexpected behavior from Rust's perspective.
|
||||
|
||||
The narrow answer lies in the diagram at the top of this page --- behind the
|
||||
The narrow answer lies in the diagram at the top of [this page][2] --- behind the
|
||||
scenes, CXX generates Rust `unsafe` and `extern "C"` functions just like
|
||||
we did manually in the previous section.
|
||||
|
||||
@ -41,3 +41,4 @@ we did manually in the previous section.
|
||||
|
||||
[0]: https://source.chromium.org/chromium/chromium/src/+/main:base/containers/span_rust.h;l=21
|
||||
[1]: https://steveklabnik.com/writing/the-cxx-debate
|
||||
[2]: ../interoperability-with-cpp.md
|
6
src/exercises/chromium/solutions.md
Normal file
6
src/exercises/chromium/solutions.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Exercise Solutions
|
||||
|
||||
Solutions to the Chromium exercises can be found in
|
||||
[this series of CLs][0].
|
||||
|
||||
[0]: https://chromium-review.googlesource.com/c/chromium/src/+/5096560
|
Loading…
Reference in New Issue
Block a user