File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -108,9 +108,15 @@ less to the client. The client does not know _how_ the result iterator is
108
108
constructed or represented, which means the representation can change in the
109
109
future without breaking client code.
110
110
111
- As of Rust 1.26 the same thing can be accomplished more concisely with the [ `impl
112
- Trait` ] feature. See the [" ` impl Trait` for returning complex types with ease"] [ impl-trait-2 ]
113
- section of the Edition Guide for more details.
111
+ Rust 1.26 also introduces the [ ` impl Trait ` ] [ ] feature, which is more consise
112
+ than the newtype pattern but with some additional has trade offs, namely with
113
+ ` impl Trait ` you are limited in what you can express. For example, returning
114
+ an iterator that impls ` Debug ` or ` Clone ` or some combination of the other
115
+ iterator extension traits can be problematic. In summary ` impl Trait ` as a
116
+ return type is probably great for internal APIs and may even be appropriate
117
+ for public APIs, but probably not in all cases. See the [ "` impl Trait ` for
118
+ returning complex types with ease"] [ impl-trait-2 ] section of the Edition Guide
119
+ for more details.
114
120
115
121
[ `impl Trait` ] : https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md
116
122
[ impl-trait-2 ] : https://rust-lang-nursery.github.io/edition-guide/rust-2018/trait-system/impl-trait-for-returning-complex-types-with-ease.html
You can’t perform that action at this time.
0 commit comments