From a5c7b96426cbddc1276ab4439ed2cc4a5689abc2 Mon Sep 17 00:00:00 2001 From: Ticki <@> Date: Tue, 21 Jul 2015 21:36:29 +0200 Subject: [PATCH 1/3] Add info about usage of 'unsafe' keyword in bindings to foreign interfaces. --- src/doc/trpl/unsafe.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/doc/trpl/unsafe.md b/src/doc/trpl/unsafe.md index 80b0c87473fa2..897795e91533e 100644 --- a/src/doc/trpl/unsafe.md +++ b/src/doc/trpl/unsafe.md @@ -100,10 +100,14 @@ that you normally can not do. Just three. Here they are: That’s it. It’s important that `unsafe` does not, for example, ‘turn off the borrow checker’. Adding `unsafe` to some random Rust code doesn’t change its -semantics, it won’t just start accepting anything. +semantics, it won’t just start accepting anything. But it will let you write +things that _do_ break some of the rules. -But it will let you write things that _do_ break some of the rules. Let’s go -over these three abilities in order. +You will also encounter the 'unsafe' keyword when writing bindings to foreign +(non-Rust) interfaces. You're encouraged to write a safe, native Rust interface +around the methods provided by the library. + +Let’s go over the basic three abilities listed, in order. ## Access or update a `static mut` From 48870d4f05177aa8e4d8439b71f39283f1880327 Mon Sep 17 00:00:00 2001 From: Ticki <@> Date: Tue, 21 Jul 2015 21:40:11 +0200 Subject: [PATCH 2/3] rust -> Rust --- src/doc/trpl/ffi.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/trpl/ffi.md b/src/doc/trpl/ffi.md index cbedf86371414..753a5a32e8a1b 100644 --- a/src/doc/trpl/ffi.md +++ b/src/doc/trpl/ffi.md @@ -340,7 +340,7 @@ libraries: Note that frameworks are only available on OSX targets. The different `kind` values are meant to differentiate how the native library -participates in linkage. From a linkage perspective, the rust compiler creates +participates in linkage. From a linkage perspective, the Rust compiler creates two flavors of artifacts: partial (rlib/staticlib) and final (dylib/binary). Native dynamic library and framework dependencies are propagated to the final artifact boundary, while static library dependencies are not propagated at @@ -350,9 +350,9 @@ artifact. A few examples of how this model can be used are: * A native build dependency. Sometimes some C/C++ glue is needed when writing - some rust code, but distribution of the C/C++ code in a library format is just + some Rust code, but distribution of the C/C++ code in a library format is just a burden. In this case, the code will be archived into `libfoo.a` and then the - rust crate would declare a dependency via `#[link(name = "foo", kind = + Rust crate would declare a dependency via `#[link(name = "foo", kind = "static")]`. Regardless of the flavor of output for the crate, the native static library @@ -361,7 +361,7 @@ A few examples of how this model can be used are: * A normal dynamic dependency. Common system libraries (like `readline`) are available on a large number of systems, and often a static copy of these - libraries cannot be found. When this dependency is included in a rust crate, + libraries cannot be found. When this dependency is included in a Rust crate, partial targets (like rlibs) will not link to the library, but when the rlib is included in a final target (like a binary), the native library will be linked in. From cf1e078bf65899f466ebe07d29732979a845a718 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 21 Jul 2015 22:09:29 +0200 Subject: [PATCH 3/3] Klabnik nit-picks ;) --- src/doc/trpl/unsafe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/unsafe.md b/src/doc/trpl/unsafe.md index 897795e91533e..1b223365bd63a 100644 --- a/src/doc/trpl/unsafe.md +++ b/src/doc/trpl/unsafe.md @@ -103,7 +103,7 @@ borrow checker’. Adding `unsafe` to some random Rust code doesn’t change its semantics, it won’t just start accepting anything. But it will let you write things that _do_ break some of the rules. -You will also encounter the 'unsafe' keyword when writing bindings to foreign +You will also encounter the `unsafe` keyword when writing bindings to foreign (non-Rust) interfaces. You're encouraged to write a safe, native Rust interface around the methods provided by the library.