• Home
  • Raw
  • Download

Lines Matching full:rust

1 {{#title extern "C++" — Rust ♡ C++}}
4 ```rust,noplayground
17 be made available to Rust, and gives the paths of the header(s) which contain
24 Type defined in C++ that are made available to Rust, but only behind an
27 ```rust,noplayground
41 returned to Rust by way of a UniquePtr.
43 **Mutability:** Unlike extern Rust types and shared types, an extern C++ type is
47 two mutable references, given that Rust doesn't have information about the size
53 CXX produces for you in Rust *do not* come with `Send` and `Sync` impls. If you
55 and need to leverage that fact from Rust, you must provide your own unsafe
58 ```rust,noplayground
74 assess if you are coming from a Rust background. For example the
82 "Rust"](extern-rust.md)*** functions and methods. In particular, any signature
84 exposed to Rust as a method.
92 the C++ function is safe or unsafe to be called from Rust.
100 ```rust,noplayground
117 C++ types holding borrowed data may be described naturally in Rust by an extern
134 we'd want to expose this to Rust as:
136 ```rust,noplayground
155 Extern C++ types support a syntax for declaring that a Rust binding of the
157 avoids generating a fresh new binding which Rust's type system would consider
160 ```rust,noplayground
167 extern "Rust" {
173 In this case rather than producing a unique new Rust type `ffi::MyType` for the
174 Rust binding of C++'s `::path::to::MyType`, CXX will reuse the already existing
193 then both macro expansions would produce their own separate Rust type called
197 an extern type alias of the other, making them the same type in Rust.
199 ```rust,noplayground
211 ```rust,noplayground
230 equivalent to Rust type that is the `Self` type of the impl.
232 ```rust,noplayground
264 is soundly relocatable by Rust's move semantics. A C++ type is only okay to hold
265 and pass around by value in Rust if its [move constructor is trivial] and it has
268 handled by Rust only behind an indirection, such as a reference or UniquePtr.
275 hold by value and move in Rust, you can specify:
277 ```rust,noplayground
294 internal trait impls connecting the Rust API of UniquePtr and CxxVector to
301 ```rust,noplayground
322 // Rust trait error: CXX processing this module has no visibility into
334 the Rust crate hierarchy by writing `impl UniquePtr<A> {}` inside of the bridge
338 ```rust,noplayground