Skip to content

Commit 3d0237b

Browse files
committed
Extend external block section with statics
1 parent 7ebfe25 commit 3d0237b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/items/external-blocks.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@
2929
> _NamedFunctionParametersWithVariadics_ :\
3030
> &nbsp;&nbsp; ( _NamedFunctionParam_ `,` )<sup>\*</sup> _NamedFunctionParam_ `,` `...`
3131
32-
External blocks form the basis for Rust's foreign function interface.
33-
Declarations in an external block describe symbols in external libraries.
32+
External blocks provide _declarations_ of items that are not _defined_ in the
33+
current crate and are the basis of Rust's foreign function interface. Using
34+
items declared in external blocks is `unsafe`.
35+
36+
Two kind of item _declarations_ are allowed in external blocks:
37+
[functions](function.md) and [statics](static-items.md).
3438

3539
Functions within external blocks are declared in the same way as other Rust
3640
functions, with the exception that they may not have a body and are instead
@@ -47,6 +51,8 @@ extern "abi" for<'l1, ..., 'lm> fn(A1, ..., An) -> R`, where `'l1`, ... `'lm`
4751
are its lifetime parameters, `A1`, ..., `An` are the declared types of its
4852
parameters and `R` is the declared return type.
4953

54+
Statics within external blocks are declared in the same way as other Rust statics,
55+
with the exception that they may not have an expression initializing their value.
5056
It is `unsafe` to access a static item declared in an extern block, whether or
5157
not it's mutable.
5258

0 commit comments

Comments
 (0)