Comprehensive Rust(Ukrainian) 202412Дивлячись на Godbolt або Playground, можна побачити, що в цьому випадку повернення значення залежить від ABI, наприклад, на amd64 два i32, що складають точку, будуть повернуті у 2х регістрах (eax і edx). 22 будь-яка функція C може мати невизначену поведінку за довільних обставин. У цьому прикладі "C" - це ABI; інші ABI також доступні. Написання небезпечних функцій Насправді ми не будемо використовувати вказівники взаємодії з найменшим спільним знаменником - C. І C++, і Rust можуть оголошувати та викликати функції C ABI на мові C. Пізніше у курсі ми підключимо C++ безпосередньо до Rust. Тут потрібен allow_unsafe = true0 码力 | 396 页 | 1.08 MB | 10 月前3
Comprehensive Rust(Persian ) 202412� � � Godbolt � � Playground � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ABI � � � � � � � � � � � � � � � � � � � � � � � amd64 � � � i32 � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � . � � � � � � � � � � � � � � � " C " � � � � � � � � � ABI � � � . ABI � � � � � � � � � � � � � � � � � � � � � � . � � � � � � � � � � � � � � � � � � � � � � � � � ( • � � � � � � � � � � � � � Thunk � � � FFI ) � � � � � � � � � � � � � � � � � � � � � � C-ABI � � � � � � � � ( � � � � � � � � � � � � � � � � � C ) � � � � � � � � � � � � � � � � � � � � � �0 码力 | 393 页 | 987.97 KB | 10 月前3
Comprehensive Rust(简体中文) 202412general any C function might have undefined behaviour under any arbitrary circumstances. 本例中的“C”是 ABI;也可以使用其他 ABI。 编写 Unsafe 函数 We wouldn't actually use pointers for a swap function - it can be done safely +/main:build/rust/rust_static_library.gni;l=16) • 关于 [#[no_mangle]] 的详细信息 (https://doc.rust-lang.org/beta/reference/abi.html#the- no_mangle-attribute) • 关于 [extern "C"] 的详细信息 (https://doc.rust-lang.org/std/keyword.extern md#compilation-database) • 如何在 VSCode 中安装 rust-analyzer 此示例很独特,因为其归根结底是最通用的互操作语言,即 C 语言。C++ 和 Rust 本身都可以声明和调用 C ABI 函数。在本课程的稍后部分,我们会直接将 C++ 和 Rust 关联起来。 此处需要使用 allow_unsafe = true,因为#[no_mangle] 可能会支持 Rust 生成两个同名函数,0 码力 | 359 页 | 1.33 MB | 10 月前3
Comprehensive Rust(English) 202412Looking at Godbolt or Playground, one can see that in this case, the return of the value depends on the ABI, e.g. on amd64 the two i32 that is making up the point will be returned in 2 registers (eax and edx) might have undefined behaviour under any arbitrary circumstances. The "C" in this example is the ABI; other ABIs are available too. Writing Unsafe Functions We wouldn't actually use pointers for a swap the lowest-common-denominator interop language, C. Both C++ and Rust can natively declare and call C ABI functions. Later in the course, we'll connect C++ directly to Rust. allow_unsafe = true is required0 码力 | 382 页 | 1.00 MB | 10 月前3
Comprehensive Rust ?Looking at Godbolt or Playground, one can see that in this case, the return of the value depends on the ABI, e.g. on amd64 the two i32 that is making up the point will be returned in 2 registers (eax and edx) might have undefined behaviour under any arbitrary circumstances. The "C" in this example is the ABI; other ABIs are available too. Writing Unsafe Functions We wouldn't actually use pointers for a swap the lowest-common-denominator interop language, C. Both C++ and Rust can natively declare and call C ABI functions. Later in the course, we'll connect C++ directly to Rust. allow_unsafe = true is required0 码力 | 378 页 | 1009.46 KB | 1 年前3
Comprehensive Rust(Español) 202412Mirando en Godbolt o Playground, uno puede ver que en este caso el valor de retorno dependen del ABI, e.g. en amd64 los dos i32 que constituyen el punto son regresados en 2 registros (eax y edx). 22 have undefined behaviour under any arbitrary circumstances. En este ejemplo, "C" es la ABI.; también hay otras ABI disponibles. Escribir Funciones Unsafe (Inseguras) We wouldn't actually use pointers mínimo común denominador, C. Tanto C++ como Rust pueden declarar y llamar de forma nativa funciones ABI de C. Más adelante, conectaremos C++ directamente con Rust. 246 allow_unsafe = true es obligatorio0 码力 | 389 页 | 1.04 MB | 10 月前3
Comprehensive Rust(繁体中文)any C function might have undefined behaviour under any arbitrary circumstances. 此例中的 "C" 為 ABI;您也可以使用其他 ABI。 編寫不安全的函式 We wouldn't actually use pointers for a swap function - it can be done safely with switch 相關資訊 • 如何在 VSCode 中安裝 rust-analyzer 此範例會探究做為最小公因數的互通語言 C,因此很特別。C++ 和 Rust 都能以原生方式宣告及呼叫 C ABI 函式。本課程稍後會將 C++ 直接連結至 Rust。 這裡需要 allow_unsafe = true,因為#[no_mangle] 可能會允許 Rust 產生兩個名稱相同的函 式,Rust 就不再能保證系統會呼叫正確的函式。 • 這項工具會自動為非 C 功能產生 FFI 替換程式 (與 C-ABI 相容的小型、可自由使用的函式),例如讓 FFI 呼叫 Rust 或 C++ 方法;手動繫結會需要手動編寫這類頂層的、可自由使用的函式 • 這項工具和程式庫可處理一組核心型別,例如: – &[T] 傳遞時可以跨越 FFI 邊界,但無法保證任何特定 ABI 或記憶體布局。使用手動繫結時, std::span/&[T] 0 码力 | 358 页 | 1.41 MB | 10 月前3
Comprehensive Rust(Português do Brasil) 202412otimização. Olhando para Godbolt ou Playground, pode-se ver que, neste caso, o retorno do valor depende do ABI, por exemplo, no amd64 os dois i32 que compõem o ponto serão retornados em 2 registradores (eax e edx) pode ter comportamento indefinido sob quaisquer circunstâncias arbitrárias. O "C" neste exemplo é o ABI; outros ABIs também estão disponíveis. Escrevendo Funções Inseguras Na verdade, não usaríamos ponteiros de menor denominador comum, C. Tanto C++ quanto Rust podem declarar e chamar nativamente funções C ABI. Mais tarde no curso, conectaremos C++ diretamente ao Rust. allow_unsafe = true é necessário aqui0 码力 | 389 页 | 1.05 MB | 10 月前3
Comprehensive Rust(繁体中文) 202406any C function might have undefined behaviour under any arbitrary circumstances. 此例中的 "C" 為 ABI;您也可以使用其他 ABI。 編寫不安全的函式 We wouldn't actually use pointers for a swap function - it can be done safely with switch 相關資訊 • 如何在 VSCode 中安裝 rust-analyzer 此範例會探究做為最小公因數的互通語言 C,因此很特別。C++ 和 Rust 都能以原生方式宣告及呼叫 C ABI 函式。本課程稍後會將 C++ 直接連結至 Rust。 這裡需要 allow_unsafe = true,因為#[no_mangle] 可能會允許 Rust 產生兩個名稱相同的函 式,Rust 就不再能保證系統會呼叫正確的函式。 • 這項工具會自動為非 C 功能產生 FFI 替換程式 (與 C-ABI 相容的小型、可自由使用的函式),例如讓 FFI 呼叫 Rust 或 C++ 方法;手動繫結會需要手動編寫這類頂層的、可自由使用的函式 • 這項工具和程式庫可處理一組核心型別,例如: – &[T] 傳遞時可以跨越 FFI 邊界,但無法保證任何特定 ABI 或記憶體布局。使用手動繫結時, std::span/&[T] 0 码力 | 356 页 | 1.41 MB | 1 年前3
Comprehensive Rust(日语) 202412Looking at Godbolt or Playground, one can see that in this case, the return of the value depends on the ABI, e.g. on amd64 the two i32 that is making up the point will be returned in 2 registers (eax and edx) any C function might have undefined behaviour under any arbitrary circumstances. この例の "C" は ABI です(他の ABI も使用できます)。 Unsafe 関数の書き方 実際には、swap 関数ではポインタは使用しません。これは参照を使用することで安全に実行できま す。 アンセーフな関数内では、アンセーフなコードを • VSCode に rust-analyzer をインストールする方法 この例は、共通の相互運用言語である C に集約されているため、一般的ではありません。C++ と Rust はどちらも、C ABI 関数をネイティブに宣言して呼び出すことができます。コースの後半で、C++ を Rust に直接接続します。 allow_unsafe = true is required here because0 码力 | 381 页 | 1.36 MB | 10 月前3
共 20 条
- 1
- 2













