diff options
| author | Christopher Vittal <christopher.vittal@gmail.com> | 2017-11-10 15:51:28 -0500 |
|---|---|---|
| committer | Christopher Vittal <christopher.vittal@gmail.com> | 2017-11-15 15:46:01 -0500 |
| commit | b4c1aef1ca575e39481ea6c3295fc6b44f78f952 (patch) | |
| tree | 6d8bd8056294544774a4e5444761b580c03428f4 /src/doc | |
| parent | 04ad8fd7a50ecd2c06556455cf25cc29fced1812 (diff) | |
| download | rust-b4c1aef1ca575e39481ea6c3295fc6b44f78f952.tar.gz rust-b4c1aef1ca575e39481ea6c3295fc6b44f78f952.zip | |
Add universal_impl_trait unstable-book entry
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/unstable-book/src/language-features/universal-impl-trait.md | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/universal-impl-trait.md b/src/doc/unstable-book/src/language-features/universal-impl-trait.md new file mode 100644 index 00000000000..6b3c5e92720 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/universal-impl-trait.md @@ -0,0 +1,32 @@ +# `universal_impl_trait` + +The tracking issue for this feature is: [#34511]. + +[#34511]: https://github.com/rust-lang/rust/issues/34511 + +-------------------- + +The `universal_impl_trait` feature extends the [`conservative_impl_trait`] +feature allowing the `impl Trait` syntax in arguments (universal +quantification). + +[`conservative_impl_trait`]: ./language-features/conservative-impl-trait.html + +## Examples + +```rust +#![feature(universal_impl_trait)] +use std::ops::Not; + +fn any_zero(values: impl IntoIterator<Item = i32>) -> bool { + for val in values { if val == 0 { return true; } } + false +} + +fn main() { + let test1 = -5..; + let test2 = vec![1, 8, 42, -87, 60]; + assert!(any_zero(test1)); + assert!(bool::not(any_zero(test2))); +} +``` |
