about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Regueiro <alexreg@me.com>2018-09-21 01:24:52 +0100
committerAlexander Regueiro <alexreg@me.com>2018-09-25 03:09:47 +0100
commit16cf404f9853e716a216be32d05f5215ff821c00 (patch)
treeda8636b2e4e48a3b57e469fe9ab7877f52b26c5f
parent3b1445022571b444ce45825c88ff59a1b80e1b37 (diff)
downloadrust-16cf404f9853e716a216be32d05f5215ff821c00.tar.gz
rust-16cf404f9853e716a216be32d05f5215ff821c00.zip
Added section to Unstable Book.
-rw-r--r--src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md b/src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md
new file mode 100644
index 00000000000..896465cf649
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md
@@ -0,0 +1,28 @@
+# `impl_trait_in_bindings`
+
+The tracking issue for this feature is: [#34511]
+
+[#34511]: https://github.com/rust-lang/rust/issues/34511
+
+------------------------
+
+The `impl_trait_in_bindings` feature gate lets you use `impl Trait` syntax in
+`let`, `static`, and `const` bindings.
+
+A simple example is:
+
+```rust
+#![feature(impl_trait_in_bindings)]
+
+use std::fmt::Debug;
+
+fn main() {
+    let a: impl Debug + Clone = 42;
+    let b = a.clone();
+    println!("{:?}", b); // prints `42`
+}
+```
+
+Note however that because the types of `a` and `b` are opaque in the above
+example, calling inherent methods or methods outside of the specified traits
+(e.g., `a.abs()` or `b.abs()`) is not allowed, and yields an error.