Skip to content

Commit 2c49e91

Browse files
authored
Merge pull request #178 from dwijnand/patch-1
Update C-NEWTYPE-HIDE now impl Trait is shipped
2 parents 05a1d5e + 3e82943 commit 2c49e91

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/future-proofing.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,19 @@ less to the client. The client does not know _how_ the result iterator is
108108
constructed or represented, which means the representation can change in the
109109
future without breaking client code.
110110

111-
In the future the same thing can be accomplished more concisely with the [`impl
112-
Trait`] feature but this is currently unstable.
111+
Rust 1.26 also introduces the [`impl Trait`][] feature, which is more concise
112+
than the newtype pattern but with some additional trade offs, namely with `impl
113+
Trait` you are limited in what you can express. For example, returning an
114+
iterator that impls `Debug` or `Clone` or some combination of the other iterator
115+
extension traits can be problematic. In summary `impl Trait` as a return type
116+
is probably great for internal APIs and may even be appropriate for public APIs,
117+
but probably not in all cases. See the ["`impl Trait` for returning complex
118+
types with ease"][impl-trait-2] section of the Edition Guide for more details.
113119

114120
[`impl Trait`]: https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md
121+
[impl-trait-2]: https://rust-lang-nursery.github.io/edition-guide/rust-2018/trait-system/impl-trait-for-returning-complex-types-with-ease.html
115122

116123
```rust
117-
#![feature(conservative_impl_trait)]
118-
119124
pub fn my_transform<I: Iterator>(input: I) -> impl Iterator<Item = (usize, I::Item)> {
120125
input.skip(3).enumerate()
121126
}

0 commit comments

Comments
 (0)