]> git.proxmox.com Git - rustc.git/blob - src/doc/unstable-book/src/language-features/universal-impl-trait.md
New upstream version 1.23.0+dfsg1
[rustc.git] / src / doc / unstable-book / src / language-features / universal-impl-trait.md
1 # `universal_impl_trait`
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 `universal_impl_trait` feature extends the [`conservative_impl_trait`]
10 feature allowing the `impl Trait` syntax in arguments (universal
11 quantification).
12
13 [`conservative_impl_trait`]: ./language-features/conservative-impl-trait.html
14
15 ## Examples
16
17 ```rust
18 #![feature(universal_impl_trait)]
19 use std::ops::Not;
20
21 fn any_zero(values: impl IntoIterator<Item = i32>) -> bool {
22 for val in values { if val == 0 { return true; } }
23 false
24 }
25
26 fn main() {
27 let test1 = -5..;
28 let test2 = vec![1, 8, 42, -87, 60];
29 assert!(any_zero(test1));
30 assert!(bool::not(any_zero(test2)));
31 }
32 ```