File tree 1 file changed +28
-0
lines changed
src/doc/unstable-book/src/language-features
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ` impl_trait_in_bindings `
2
+
3
+ The tracking issue for this feature is: [ #34511 ]
4
+
5
+ [ #34511 ] : https://github.com/rust-lang/rust/issues/34511
6
+
7
+ ------------------------
8
+
9
+ The ` impl_trait_in_bindings ` feature gate lets you use ` impl Trait ` syntax in
10
+ ` let ` , ` static ` , and ` const ` bindings.
11
+
12
+ A simple example is:
13
+
14
+ ``` rust
15
+ #![feature(impl_trait_in_bindings)]
16
+
17
+ use std :: fmt :: Debug ;
18
+
19
+ fn main () {
20
+ let a : impl Debug + Clone = 42 ;
21
+ let b = a . clone ();
22
+ println! (" {:?}" , b ); // prints `42`
23
+ }
24
+ ```
25
+
26
+ Note however that because the types of ` a ` and ` b ` are opaque in the above
27
+ example, calling inherent methods or methods outside of the specified traits
28
+ (e.g., ` a.abs() ` or ` b.abs() ` ) is not allowed, and yields an error.
You can’t perform that action at this time.
0 commit comments