Home
last modified time | relevance | path

Searched refs:Rust (Results 1 – 25 of 325) sorted by relevance

12345678910>>...13

/third_party/rust/crates/cxx/book/src/
Dextern-rust.md1 {{#title extern "Rust" — Rust ♡ C++}}
2 # extern "Rust"
7 extern "Rust" {
13 The `extern "Rust"` section of a CXX bridge declares Rust types and signatures
16 The CXX code generator uses your extern "Rust" section(s) to produce a C++
18 has the same path as the Rust source file containing the bridge, except with a
21 A bridge module may contain zero or more extern "Rust" blocks.
23 ## Opaque Rust types
25 Types defined in Rust that are made available to C++, but only behind an
31 extern "Rust" {
[all …]
Dreference.md1 {{#title The bridge module — Rust ♡ C++}}
9 - ***[extern "Rust"](extern-rust.md)*** — exposing opaque Rust types, Rust
10 functions, Rust methods to C++; functions with lifetimes.
15 structures across a CXX bridge; Rust orphan-rule-compatible way to request
19 Rust as source of truth vs C++ as source of truth.
25 Rust.
28 the language boundary; accessing a Rust error message from C++; customizing
29 the set of caught exceptions and their conversion to a Rust error message.
Dindex.md5 # CXX — safe interop between Rust and C++
7 This library provides a safe mechanism for calling C++ code from Rust and Rust
8 code from C++. It carves out a regime of commonality where Rust and C++ are
19 of the types and function signatures to protect both Rust's and C++'s
34 In this example we are writing a Rust application that calls a C++ client of a
43 extern "Rust" {
60 Now we simply provide Rust definitions of all the things in the `extern "Rust"`
65 this blobstore example in full detail, including all of the Rust code and all of
74 The key takeaway, which is enabled by the CXX library, is that the Rust code in
75 main.rs is 100% ordinary safe Rust code working idiomatically with Rust types
[all …]
Dattributes.md1 {{#title Attributes — Rust ♡ C++}}
7 to control the C++ namespace into which to emit extern Rust items and the
13 extern "Rust" {
33 extern "Rust" {
40 extern "Rust" {
51 Sometimes you want the Rust name of a function or type to differ from its C++
53 function name using distinct Rust names.
67 The `#[rust_name = "..."]` attribute replaces the name that Rust should use for
71 Either of the two attributes may be used on extern "Rust" as well as extern
Dcontext.md1 {{#title Other Rust–C++ interop tools — Rust ♡ C++}}
2 # Context: other Rust–C++ interop tools
4 When it comes to interacting with an idiomatic Rust API or idiomatic C++ API
15 programmatically to `extern "C"` Rust signatures. Preferably, build a
16 safe/idiomatic Rust wrapper on top.
18 - Build a C-compatible Rust wrapper around the Rust code and use **[cbindgen]**
53 containing a pointer ([bindgen#778]) and is not directly expressible in Rust.
64 Imagine Rust and C and C++ as three vertices of a scalene triangle, with length
68 The most similar pair (the shortest edge) is Rust–C++. These languages
76 C++ down to C, and C back up to Rust. The Rust–C edge always involves a
[all …]
Dextern-c++.md1 {{#title extern "C++" — Rust ♡ C++}}
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
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
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
[all …]
Dtutorial.md1 {{#title Tutorial — Rust ♡ C++}}
4 This example walks through a Rust application that calls into a C++ client of a
5 blobstore service. In fact we'll see calls going in both directions: Rust to C++
6 as well as C++ to Rust. For your own use case it may be that you need just one
19 We'll use Cargo, which is the build system commonly used by open source Rust
43 in a Rust module annotated with the `#[cxx::bridge]` attribute macro.
62 ## Calling a C++ function from Rust
68 that Rust does not need to assume anything about its implementation, not even
70 which is incompatible with Rust's move semantics, or may hold internal
71 references which cannot be modeled by Rust's borrowing system. Though there are
[all …]
/third_party/rust/crates/cxx/book/src/build/
Dother.md1 {{#title Other build systems — Rust ♡ C++}}
8 - Link the resulting objects together with your other C++ and Rust objects.
18 CXX's Rust code generation automatically happens when the `#[cxx::bridge]`
19 procedural macro is expanded during the normal Rust compilation process, so no
45 ### Linking the C++ and Rust together
47 When linking a binary which contains mixed Rust and C++ code, you will have to
48 choose between using the Rust toolchain (`rustc`) or the C++ toolchain which you
51 Rust does not generate simple standalone `.o` files, so you can't just throw the
52 Rust-generated code into your existing C++ toolchain linker. Instead you need to
55 * Use `rustc` as the final linker. Pass any non-Rust libraries using `-L
[all …]
/third_party/rust/crates/cxx/book/src/binding/
Dcxxvector.md1 {{#title std::vector<T> — Rust ♡ C++}}
4 The Rust binding of std::vector\<T\> is called **[`CxxVector<T>`]**. See the
5 link for documentation of the Rust API.
11 Rust code can never obtain a CxxVector by value. Instead in Rust code we will
15 CxxVector\<T\> does not support T being an opaque Rust type. You should use a
16 Vec\<T\> (C++ rust::Vec\<T\>) instead for collections of opaque Rust types on
21 This program involves Rust code converting a `CxxVector<CxxString>` (i.e.
22 `std::vector<std::string>`) into a Rust `Vec<String>`.
33 extern "Rust" {
Dresult.md1 {{#title Result<T> — Rust ♡ C++}}
8 handle the translation of those to Rust Result\<T\> using your own shims for
16 If a panic occurs in *any* `extern "Rust"` function, regardless of whether it is
18 calls Rust's `std::process::abort`.
20 ## Returning Result from Rust to C++
22 An `extern "Rust"` function returning a Result turns into a `throw` in C++ if
23 the Rust side produces an error.
27 FFI. The Rust *implementation* (outside of the bridge module) may pick any error
35 extern "Rust" {
56 gives the error message according to the Rust error's std::fmt::Display impl.
[all …]
Duniqueptr.md1 {{#title std::unique_ptr<T> — Rust ♡ C++}}
4 The Rust binding of std::unique\_ptr\<T\> is called **[`UniquePtr<T>`]**. See
5 the link for documentation of the Rust API.
14 UniquePtr\<T\> does not support T being an opaque Rust type. You should use a
16 opaque Rust types on the language boundary.
20 UniquePtr is commonly useful for returning opaque C++ objects to Rust. This use
Dbox.md1 {{#title rust::Box<T> — Rust ♡ C++}}
55 If T is an opaque Rust type, the Rust type is required to be [Sized] i.e. size
57 sized opaque Rust types.
63 This program uses a Box to pass ownership of some opaque piece of Rust state
64 over to C++ and then back to a Rust callback, which is a useful pattern for
74 extern "Rust" {
Dcxxstring.md1 {{#title std::string — Rust ♡ C++}}
4 The Rust binding of std::string is called **[`CxxString`]**. See the link for
5 documentation of the Rust API.
11 Rust code can never obtain a CxxString by value. C++'s string requires a move
12 constructor and may hold internal pointers, which is not compatible with Rust's
13 move behavior. Instead in Rust code we will only ever look at a CxxString
17 In order to construct a CxxString on the stack from Rust, you must use the
27 keys. The example demonstrates Rust indexing into one of those maps.
Dslice.md1 {{#title rust::Slice<T> — Rust ♡ C++}}
4 - Rust `&[T]` is written `rust::Slice<const T>` in C++
5 - Rust `&mut [T]` is written `rust::Slice<T>` in C++
83 T must not be an opaque Rust type or opaque C++ type. Support for opaque Rust
90 accidentally exposing overlapping &amp;mut \[T\] to Rust is UB.
95 reading from stdin, but it could be from anywhere), then calls into Rust to
113 extern "Rust" {
/third_party/rust/crates/libc/
DREADME zh.md6 `libc`提供了所有必要的定义,以便在Rust轻松与C
7 代码(或 "类C "代码)在Rust支持的平台上的调用。这包括
48 如果你使用Rust >= 1.62,这个功能是隐式启用的。
53 ## Rust版本支持
55 目前支持的最小Rust工具链版本是**Rust 1.13.0**。(libc 目前没有任何计划关于改变最小支持的支持的 Rust 版本)。需要较新的 Rust 特性的 API 只在较新的 Rust
73 关于每个Rust工具链的`libc`保证可以在哪些平台上构建。
DREADME.md6 code (or "C-like" code) on each of the platforms that Rust supports. This
38 If you use Rust >= 1.62, this feature is implicitly enabled.
43 ## Rust version support
45 The minimum supported Rust toolchain version is currently **Rust 1.13.0**.
47 supported Rust version; such policy is a work in progress.) APIs requiring
48 newer Rust features are only available on newer Rust toolchains:
67 for the platforms on which `libc` is guaranteed to build for each Rust
93 must adhere to Rust's [Code of Conduct].
/third_party/rust/crates/cxx/
DREADME_zh.md1 CXX &mdash; Rust和C++之间的安全FFI
15 CXX通过FFI(Foreign Function Interface)和函数签名的形式来实现接口和类型声明,并对类型和函数签名进行静态分析,以维护Rust和C++的不变量和要求。
21 ### C++调用Rust接口
23 1. 在Rust侧文件lib.rs里mod ffi写清楚需要调用的C++接口,并将接口包含在extern "Rust"里面,暴露给C++侧使用。
34 extern "Rust"{
44 println!("Here is a test for cpp call Rust.");
47 println!("Here is a message from Rust,test for ffi::Shared:");
51 println!("Here is a message from Rust,test for usize:");
55 println!("Here is a message from Rust,test for String");
59 println!("Here is a message from Rust,test for {} + {} is:",n1 ,n2);
[all …]
DREADME.md1 CXX &mdash; safe FFI between Rust and C++
9 This library provides a **safe** mechanism for calling C++ code from Rust and
10 Rust code from C++, not subject to the many ways that things can go wrong when
14 project, you would be on the hook for auditing all the unsafe Rust code and
16 just the C++ side would be sufficient to catch all problems, i.e. the Rust side
42 embedded together in one Rust module (the next section shows an example). From
44 against the types and function signatures to uphold both Rust's and C++'s
50 correctness. On the Rust side this code generator is simply an attribute
60 such as Rust's `String` or C++'s `std::string`, Rust's `Box` or C++'s
61 `std::unique_ptr`, Rust's `Vec` or C++'s `std::vector`, etc in any combination.
[all …]
/third_party/rust/crates/bindgen/book/src/
Dusing-unions.md3 **NOTE**: Rust 1.19 stabilized the `union` type (see Rust issue [#32836](https://github.com/rust-la…
5 You can pass the `--rust-target` option to tell `bindgen` to target a specific version of Rust.
6 By default, `bindgen` will target the latest stable Rust.
48 Bindgen can emit one of two Rust types that correspond to C unions:
50 * Rust's `union` builtin (only available in Rust >= 1.19, including nightly)
51 * Bindgen's `BindgenUnion` (available for all Rust targets)
53 Bindgen uses the following logic to determine which Rust union type to emit:
55 * If the Rust target is >= 1.19 (including nightly) AND each field of the union can derive `Copy`, …
93 If the target Rust version does not support the new `union` type or there is a field that cannot de…
/third_party/rust/crates/bindgen/
DREADME_zh.md6 `bindgen` 自动生成Rust与C(和一些C++)库的FFI绑定。
19 `bindgen`产生Rust FFI代码,允许调用`doggo`库的函数并使用其类型:
105 下面是一个使用bindgen实现Rust调用C的示例。
142 3. 添加文件main.rs,就可以在Rust侧通过c_ffi实现对C侧的接口调用。注意Rust侧调用的不安全接口需要使用unsafe封装。
173 4. 添加构建文件BUILD.gn,建立Rust模块对C模块的依赖。
204 Minimum support Rust版本是**1.60.0**。
208 MSRV是可用于编译`bindgen`的Minimum Rust版本。`bindgen`可以生成与低于当前MSRV的Rust版本兼容的绑定。
/third_party/rust/crates/serde/
DREADME.md1 …[Latest Version]][crates.io] [![serde: rustc 1.13+]][Rust 1.13] [![serde_derive: rustc 1.31+]][Rus…
9 [Rust 1.13]: https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
10 [Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
12 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and g…
78 Serde is one of the most widely used Rust libraries so any place that Rustaceans
82 [#beginners] channels of the official Rust Project Discord (invite:
85 [/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
/third_party/rust/crates/serde/serde/
DREADME.md1 …[Latest Version]][crates.io] [![serde: rustc 1.13+]][Rust 1.13] [![serde_derive: rustc 1.31+]][Rus…
9 [Rust 1.13]: https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
10 [Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
12 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and g…
78 Serde is one of the most widely used Rust libraries so any place that Rustaceans
82 [#beginners] channels of the official Rust Project Discord (invite:
85 [/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
/third_party/rust/crates/serde/serde_derive/
DREADME.md1 …[Latest Version]][crates.io] [![serde: rustc 1.13+]][Rust 1.13] [![serde_derive: rustc 1.31+]][Rus…
9 [Rust 1.13]: https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
10 [Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
12 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and g…
78 Serde is one of the most widely used Rust libraries so any place that Rustaceans
82 [#beginners] channels of the official Rust Project Discord (invite:
85 [/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
/third_party/rust/crates/serde/serde_test/
DREADME.md1 …[Latest Version]][crates.io] [![serde: rustc 1.13+]][Rust 1.13] [![serde_derive: rustc 1.31+]][Rus…
9 [Rust 1.13]: https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
10 [Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
12 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and g…
78 Serde is one of the most widely used Rust libraries so any place that Rustaceans
82 [#beginners] channels of the official Rust Project Discord (invite:
85 [/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
/third_party/rust/crates/bitflags/
DREADME.md4 [![Rust](https://github.com/bitflags/bitflags/workflows/Rust/badge.svg)](https://github.com/bitflag…
10 A Rust macro to generate structures which behave like a set of bitflags
30 ## Rust Version Support
32 The minimum supported Rust version is 1.46 due to use of associated constants and const functions.

12345678910>>...13