From a1861ef90071d05bc583873f4d8a2d8956d13f95 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Mon, 16 Jan 2023 14:15:00 +0000 Subject: [PATCH] Add speaker notes for impl Trait. --- src/generics/impl-trait.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/generics/impl-trait.md b/src/generics/impl-trait.md index 58afd6a5..c7ec317a 100644 --- a/src/generics/impl-trait.md +++ b/src/generics/impl-trait.md @@ -18,3 +18,14 @@ fn main() { * `impl Trait` cannot be used with the `::<>` turbo fish syntax. * `impl Trait` allows you to work with types which you cannot name. + +
+ +The meaning of `impl Trait` is a bit different in the different positions. + +* For a parameter, `impl Trait` is like an anonymous generic parameter with a trait bound. +* For a return type, it means that the return type is some concrete type that implements the trait, + without naming the type. This can be useful when you don't want to expose the concrete type in a + public API. + +