Skip to content

Commit b61e4a8

Browse files
committed
---
yaml --- r: 129441 b: refs/heads/snap-stage3 c: 54bd9e6 h: refs/heads/master i: 129439: db443c6 v: v3
1 parent ee461bb commit b61e4a8

File tree

15 files changed

+137
-652
lines changed

15 files changed

+137
-652
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 566b470e138e929e8a93d613372db1ba177c494f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 4444aec1423b2f9431f30e1dc121d239c16ed71c
4+
refs/heads/snap-stage3: 54bd9e6323742de87a526931a15558319db30604
55
refs/heads/try: 80b45ddbd351f0a4a939c3a3c4e20b4defec4b35
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/doc/guide-ffi.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ struct RustObject {
268268
// other members
269269
}
270270
271-
extern fn callback(target: *mut RustObject, a:i32) {
271+
extern "C" fn callback(target: *mut RustObject, a:i32) {
272272
println!("I'm called from C with value {0}", a);
273273
unsafe {
274274
// Update the value in RustObject with the value received from the callback
@@ -506,16 +506,16 @@ to define a block for all windows systems, not just x86 ones.
506506
507507
# Interoperability with foreign code
508508
509-
Rust guarantees that the layout of a `struct` is compatible with the platform's representation in C.
510-
A `#[packed]` attribute is available, which will lay out the struct members without padding.
511-
However, there are currently no guarantees about the layout of an `enum`.
509+
Rust guarantees that the layout of a `struct` is compatible with the platform's representation in C
510+
only if the `#[repr(C)]` attribute is applied to it. `#[repr(C, packed)]` can be used to lay out
511+
struct members without padding. `#[repr(C)]` can also be applied to an enum.
512512
513-
Rust's owned and managed boxes use non-nullable pointers as handles which point to the contained
513+
Rust's owned boxes (`Box<T>`) use non-nullable pointers as handles which point to the contained
514514
object. However, they should not be manually created because they are managed by internal
515-
allocators. References can safely be assumed to be non-nullable pointers directly to the
516-
type. However, breaking the borrow checking or mutability rules is not guaranteed to be safe, so
517-
prefer using raw pointers (`*`) if that's needed because the compiler can't make as many assumptions
518-
about them.
515+
allocators. References can safely be assumed to be non-nullable pointers directly to the type.
516+
However, breaking the borrow checking or mutability rules is not guaranteed to be safe, so prefer
517+
using raw pointers (`*`) if that's needed because the compiler can't make as many assumptions about
518+
them.
519519
520520
Vectors and strings share the same basic memory layout, and utilities are available in the `vec` and
521521
`str` modules for working with C APIs. However, strings are not terminated with `\0`. If you need a

0 commit comments

Comments
 (0)