Skip to content

Commit 5aac879

Browse files
committed
Try to be more clear about definitions and declarations
1 parent ea9d02e commit 5aac879

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/items/functions.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,28 @@ component after the function name. This might be necessary if there is not
107107
sufficient context to determine the type parameters. For example,
108108
`mem::size_of::<u32>() == 4`.
109109

110-
## Extern functions
110+
## Extern function qualifier
111111

112-
Extern function _definitions_ allow defining functions that can be called
113-
with a particular ABI:
112+
The `extern` function qualifier allows providing function _definitions_ that can
113+
be called with a particular ABI:
114114

115115
```rust,ignore
116116
extern "ABI" fn foo() { ... }
117117
```
118118

119-
An extern function _declaration_ via an [external block] can be used to
120-
provide an item for these functions that can be called by Rust code without
121-
providing their definition.
119+
These are often used in combination with [external block] items which provide
120+
function _declarations_ that can be used to call functions without providing
121+
their _definition_:
122122

123-
When `"extern" Abi?*` is omitted from `FunctionQualifiers`, the ABI `"Rust"` is
124-
assigned. For example:
123+
```rust,ignore
124+
extern "ABI" {
125+
fn foo(); /* no body */
126+
}
127+
unsafe { foo() }
128+
```
129+
130+
When `"extern" Abi?*` is omitted from `FunctionQualifiers` in function items,
131+
the ABI `"Rust"` is assigned. For example:
125132

126133
```rust
127134
fn foo() {}

0 commit comments

Comments
 (0)