File tree 1 file changed +15
-15
lines changed
1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,22 @@ r[type.fn-pointer.intro]
29
29
Function pointer types, written using the ` fn ` keyword, refer to a function
30
30
whose identity is not necessarily known at compile-time.
31
31
32
+ An example where ` Binop ` is defined as a function pointer type:
33
+
34
+ ``` rust
35
+ fn add (x : i32 , y : i32 ) -> i32 {
36
+ x + y
37
+ }
38
+
39
+ let mut x = add (5 ,7 );
40
+
41
+ type Binop = fn (i32 , i32 ) -> i32 ;
42
+ let bo : Binop = add ;
43
+ x = bo (5 ,7 );
44
+ ```
45
+
32
46
r[ type.fn-pointer.coercion]
33
- They can be created via a coercion from both [ function items] and non-capturing, non-async [ closures] .
47
+ Function pointers can be created via a coercion from both [ function items] and non-capturing, non-async [ closures] .
34
48
35
49
r[ type.fn-pointer.qualifiers]
36
50
The ` unsafe ` qualifier indicates that the type's value is an [ unsafe
@@ -47,20 +61,6 @@ these calling conventions:
47
61
* ` win64 `
48
62
* ` efiapi `
49
63
50
- An example where ` Binop ` is defined as a function pointer type:
51
-
52
- ``` rust
53
- fn add (x : i32 , y : i32 ) -> i32 {
54
- x + y
55
- }
56
-
57
- let mut x = add (5 ,7 );
58
-
59
- type Binop = fn (i32 , i32 ) -> i32 ;
60
- let bo : Binop = add ;
61
- x = bo (5 ,7 );
62
- ```
63
-
64
64
r[ type.fn-pointer.attributes]
65
65
## Attributes on function pointer parameters
66
66
You can’t perform that action at this time.
0 commit comments