references must be aligned; also move up the warning that fn ptrs must be non-NULL
This commit is contained in:
parent
21b502b275
commit
2e6b13a649
1 changed files with 8 additions and 7 deletions
|
@ -895,9 +895,9 @@ mod prim_usize { }
|
||||||
/// A reference represents a borrow of some owned value. You can get one by using the `&` or `&mut`
|
/// A reference represents a borrow of some owned value. You can get one by using the `&` or `&mut`
|
||||||
/// operators on a value, or by using a `ref` or `ref mut` pattern.
|
/// operators on a value, or by using a `ref` or `ref mut` pattern.
|
||||||
///
|
///
|
||||||
/// For those familiar with pointers, a reference is just a pointer that is assumed to not be null.
|
/// For those familiar with pointers, a reference is just a pointer that is assumed to be
|
||||||
/// In fact, `Option<&T>` has the same memory representation as a nullable pointer, and can be
|
/// aligned and not null. In fact, `Option<&T>` has the same memory representation as a
|
||||||
/// passed across FFI boundaries as such.
|
/// nullable but aligned pointer, and can be passed across FFI boundaries as such.
|
||||||
///
|
///
|
||||||
/// In most cases, references can be used much like the original value. Field access, method
|
/// In most cases, references can be used much like the original value. Field access, method
|
||||||
/// calling, and indexing work the same (save for mutability rules, of course). In addition, the
|
/// calling, and indexing work the same (save for mutability rules, of course). In addition, the
|
||||||
|
@ -1040,6 +1040,11 @@ mod prim_ref { }
|
||||||
/// [`FnMut`]: ops/trait.FnMut.html
|
/// [`FnMut`]: ops/trait.FnMut.html
|
||||||
/// [`FnOnce`]: ops/trait.FnOnce.html
|
/// [`FnOnce`]: ops/trait.FnOnce.html
|
||||||
///
|
///
|
||||||
|
/// Function pointers are pointers that point to *code*, not data. They can be called
|
||||||
|
/// just like functions. Like references, function pointers are assumed to not be null,
|
||||||
|
/// so if you want to pass a function pointer over FFI and be able to accommodate null pointers,
|
||||||
|
/// make your type `Option<fn()>` with your required signature.
|
||||||
|
///
|
||||||
/// Plain function pointers are obtained by casting either plain functions, or closures that don't
|
/// Plain function pointers are obtained by casting either plain functions, or closures that don't
|
||||||
/// capture an environment:
|
/// capture an environment:
|
||||||
///
|
///
|
||||||
|
@ -1095,10 +1100,6 @@ mod prim_ref { }
|
||||||
///
|
///
|
||||||
/// These markers can be combined, so `unsafe extern "stdcall" fn()` is a valid type.
|
/// These markers can be combined, so `unsafe extern "stdcall" fn()` is a valid type.
|
||||||
///
|
///
|
||||||
/// Like references in rust, function pointers are assumed to not be null, so if you want to pass a
|
|
||||||
/// function pointer over FFI and be able to accommodate null pointers, make your type
|
|
||||||
/// `Option<fn()>` with your required signature.
|
|
||||||
///
|
|
||||||
/// Function pointers implement the following traits:
|
/// Function pointers implement the following traits:
|
||||||
///
|
///
|
||||||
/// * [`Clone`]
|
/// * [`Clone`]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue