From b4c1aef1ca575e39481ea6c3295fc6b44f78f952 Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Fri, 10 Nov 2017 15:51:28 -0500 Subject: Add universal_impl_trait unstable-book entry --- .../src/language-features/universal-impl-trait.md | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/doc/unstable-book/src/language-features/universal-impl-trait.md (limited to 'src') 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) -> 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))); +} +``` -- cgit 1.4.1-3-g733a5