From 288fb5198de14a150c4f6d7e2edf7b85d1f268c1 Mon Sep 17 00:00:00 2001 From: Alexis Beingessner Date: Fri, 19 Jun 2015 15:42:30 -0700 Subject: [PATCH] remove ffi and no_std, TRPL's got it --- ffi.md | 45 --------------------------------------------- intro.md | 2 -- no_std.md | 2 -- 3 files changed, 49 deletions(-) delete mode 100644 ffi.md delete mode 100644 no_std.md diff --git a/ffi.md b/ffi.md deleted file mode 100644 index 668befb..0000000 --- a/ffi.md +++ /dev/null @@ -1,45 +0,0 @@ -% Interfacing with other Languages (FFI) - -*Obviously* we'd all love to live in a **glorious** world where everything is -written in Rust, Rust, and More Rust. Tragically, programs have been written -in Not Rust for over 50 years. Crufty enterprises are doomed to -support ancient code bases, and greybeard programmers stuck in their ways -*insist* on writing programs in other languages, even to this day! - -In all seriousness, there's a myriad of reasons for your codebase to be a -hybrid of different languages, and Rust is well-designed to interface with -all of them as painlessly as possible. It does this through the tried and -true strategy of all languages: pretend to be C, and understand C. - -Thanks to Rust's minimal runtime and C-like semantics, this is about as -painless as FFI with C++. Obviously, most of Rust's features are completely -incompatible with other languages: tagged unions, zero-sized-types, dynamically- -sized types, destructors, methods, traits, references, and lifetimes are all -concepts that you won't be able to expose or accept in your foreign function -interface. - -All mapping through C will give you is functions, structs, globals, raw pointers, -and C-like enums. That's it. Rust's default data layouts are also incompatible -with the C layout. See [the section on data layout][data.html] for details. -Long story short: mark FFI structs and enums with `#[repr(C)]`, mark FFI -functions as `extern`. - -## Runtime - -Rust's runtime is sufficiently minimal that it requires *no* special handling. -You don't need to set anything up. You don't need to tear anything down. -Awesome. - -The only runtime detail you *really* need to worry about is unwinding. Rust's -unwinding model is not defined to be incompatible with any particular language. -That means that if you call Rust from another language and it unwinds into the -calling language, this will cause Undefined Behaviour. Similarly, if another -language unwinds into Rust, it will also cause Undefined Behaviour. - -Rust can't really do anything about other languages unwinding into it (FFI is unsafe -for a reason!), but you can be a good FFI citizen by catching panics in any -FFI functions you export. Rust provides `thread::catch_panic` for exactly this. -Unfortunately, this API is still unstable. - -## libc - diff --git a/intro.md b/intro.md index cb644c5..12b105d 100644 --- a/intro.md +++ b/intro.md @@ -15,8 +15,6 @@ stack or heap, we will not explain the syntax. * [Uninitialized Memory](uninitialized.html) * [Ownership-oriented resource management (RAII)](raii.html) * [Concurrency](concurrency.html) -* [Interfacing with other languages (FFI)](ffi.html) -* [Eliminating the Runtime (no_std)](no_std.html) ## A Tale Of Two Languages diff --git a/no_std.md b/no_std.md deleted file mode 100644 index 8da5b78..0000000 --- a/no_std.md +++ /dev/null @@ -1,2 +0,0 @@ -% Eliminating the Runtime (no_std) -