File tree 2 files changed +36
-1
lines changed
src/doc/unstable-book/src
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ has explictly opted out via a _negative impl_.
15
15
[ `Send` ] : https://doc.rust-lang.org/std/marker/trait.Send.html
16
16
[ `Sync` ] : https://doc.rust-lang.org/std/marker/trait.Sync.html
17
17
18
- ``` rust
18
+ ``` rust, ignore
19
19
impl !Type for Trait
20
20
```
21
21
Original file line number Diff line number Diff line change
1
+ # ` fn_traits `
2
+
3
+ The tracking issue for this feature is [ #29625 ]
4
+
5
+ See Also: [ ` unboxed_closures ` ] ( language-features/unboxed_closures.md )
6
+
7
+ [ #29625 ] : https://github.com/rust-lang/rust/issues/29625
8
+
9
+ ----
10
+
11
+ The ` fn_traits ` feature allows for implementation of the [ ` Fn* ` ] traits
12
+ for creating custom closure-like types.
13
+
14
+ [ `Fn*` ] : https://doc.rust-lang.org/std/ops/trait.Fn.html
15
+
16
+ ``` rust
17
+ #![feature(unboxed_closures)]
18
+ #![feature(fn_traits)]
19
+
20
+ struct Adder {
21
+ a : u32
22
+ }
23
+
24
+ impl FnOnce <(u32 , )> for Adder {
25
+ type Output = u32 ;
26
+ extern " rust-call" fn call_once (self , b : (u32 , )) -> Self :: Output {
27
+ self . a + b . 0
28
+ }
29
+ }
30
+
31
+ fn main () {
32
+ let adder = Adder { a : 3 };
33
+ assert_eq! (adder (2 ), 5 );
34
+ }
35
+ ```
You can’t perform that action at this time.
0 commit comments