Skip to content

Update C-NEWTYPE-HIDE now impl Trait is shipped #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 3, 2018

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Sep 3, 2018

No description provided.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, I think the change in this PR is correct, but I do have some concerns here. Namely, the way this is worded makes it seem like using impl Trait for these cases in public APIs is at least as good as using a newtype, but there are trade offs to consider here that I think might be worthwhile mentioning. Namely, with impl Trait, you are limited in what you can express. For example, returning an iterator that impls Debug or Clone or some combination of the other iterator extension traits can be problematic.

What I mean to say is that impl Trait as a return type is probably great for internal APIs and may even be appropriate for public APIs, but probably not in all cases.


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

```rust
#![feature(conservative_impl_trait)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should remove this too?

@dwijnand
Copy link
Member Author

dwijnand commented Sep 3, 2018

I remember your comments on Reddit about it, now. 😄

WDYT?

@BurntSushi
Copy link
Member

LGTM. cc @dtolnay

@dtolnay dtolnay merged commit 2c49e91 into rust-lang:master Sep 3, 2018
@dwijnand dwijnand deleted the patch-1 branch September 3, 2018 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants