Skip to content
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

Update section on "existential type" to "opaque type" #402

Merged
merged 1 commit into from
Aug 29, 2019

Conversation

varkor
Copy link
Member

@varkor varkor commented Jul 31, 2019

Updates the guide as per the changes in rust-lang/rfcs#2515.

@Centril
Copy link
Contributor

Centril commented Aug 3, 2019

cc rust-lang/rust#63063

@mark-i-m
Copy link
Member

Ping @varkor there are some comments waiting for you

@varkor
Copy link
Member Author

varkor commented Aug 28, 2019

Addressed the comments.

@mark-i-m mark-i-m merged commit 20d27f2 into rust-lang:master Aug 29, 2019
@mark-i-m
Copy link
Member

Thanks!

express that type by using the opaque type in a "defining use site".

```rust,ignore
struct Struct;
Copy link

Choose a reason for hiding this comment

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

Shouldn't it be struct Foo; ?

Copy link
Member Author

@varkor varkor Sep 17, 2019

Choose a reason for hiding this comment

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

Yes it should! Feel free to open a PR with a fix :)

Edit: I misread. See comment below.

Copy link

Choose a reason for hiding this comment

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

Then the whole example should be

fn foo() -> impl Bar {
    struct Foo;
    impl Bar for Foo { /* stuff */ }
    Foo
}

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I misread earlier. Really, this code snippet should be read in the context of the previous one. But that's confusing, so maybe we should add the definition of Foo here too. So the complete snippet would be:

type Foo = impl Bar;

struct Struct;

impl Bar for Struct { /* stuff */ }

fn foo() -> Foo {
    Struct
}

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.

None yet

6 participants