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

Allow naming the projected types #202

Merged
merged 1 commit into from
May 18, 2020
Merged

Allow naming the projected types #202

merged 1 commit into from
May 18, 2020

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented May 6, 2020

By passing an argument with the same name as the method to the attribute, you can name the projection type returned from the method:

#[pin_project(
    Replace,
    project = StructProj,
    project_ref = StructProjRef,
    project_replace = StructProjOwn,
)]
struct Struct<T> {
    #[pin]
    field: T,
}

let mut x = Struct { field: 0 };
let StructProj { field } = Pin::new(&mut x).project();
let StructProjRef { field } = Pin::new(&x).project_ref();
let StructProjOwn { field } = Pin::new(&mut x).project_replace(Struct { field: 1 });

cc #43
Closes #124

TODO:

@taiki-e taiki-e force-pushed the naming branch 2 times, most recently from 5d6a07f to e875c5a Compare May 7, 2020 02:59
@taiki-e taiki-e added the A-pin-projection Area: #[pin_project] label May 7, 2020
@taiki-e taiki-e added the S-blocked Status: Blocked on something else label May 7, 2020
bors bot added a commit that referenced this pull request May 7, 2020
211: Hide generated items from --document-private-items r=taiki-e a=taiki-e

All of the generated items are private items, but it can be displayed in the document by using the `--document-private-items` flag.

Naming will be allowed by #202, so it would probably be preferable to only display it in the document if the user did a naming.

cc #124 #202
Related: #192

Co-authored-by: Taiki Endo <te316e89@gmail.com>
@taiki-e taiki-e force-pushed the naming branch 12 times, most recently from fb617bf to 2e1e542 Compare May 8, 2020 12:54
@taiki-e taiki-e mentioned this pull request May 8, 2020
@taiki-e taiki-e force-pushed the naming branch 2 times, most recently from 0fab113 to bb40a68 Compare May 8, 2020 13:06
bors bot added a commit that referenced this pull request May 8, 2020
214: Various cleanup r=taiki-e a=taiki-e

Separated from #202 as unrelated changes.

Co-authored-by: Taiki Endo <te316e89@gmail.com>
@taiki-e taiki-e force-pushed the naming branch 6 times, most recently from 0442575 to 7657fde Compare May 8, 2020 22:37
@taiki-e taiki-e removed the S-blocked Status: Blocked on something else label May 9, 2020
@taiki-e taiki-e mentioned this pull request May 9, 2020
bors bot added a commit that referenced this pull request May 9, 2020
219: Implement !Unpin option r=taiki-e a=taiki-e

## Example

```rust
#[pin_project(!Unpin)]
struct Struct<T, U> {
    #[pin]
    pinned: T,
    unpinned: U,
}
```

Also, bump MSRV to 1.34 because `unrestricted_attribute_tokens` requires 1.34 (#202 also requires 1.34).


Closes #108 


Co-authored-by: Taiki Endo <te316e89@gmail.com>
@taiki-e taiki-e marked this pull request as ready for review May 9, 2020 12:36
@taiki-e taiki-e force-pushed the naming branch 3 times, most recently from 07754b7 to fe90f03 Compare May 10, 2020 16:55
@taiki-e taiki-e closed this May 17, 2020
@taiki-e taiki-e deleted the naming branch May 17, 2020 19:54
@taiki-e taiki-e restored the naming branch May 17, 2020 19:55
@taiki-e taiki-e reopened this May 17, 2020
@taiki-e taiki-e force-pushed the naming branch 2 times, most recently from ae3caf7 to ac0f614 Compare May 18, 2020 12:00
@taiki-e
Copy link
Owner Author

taiki-e commented May 18, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented May 18, 2020

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pin-projection Area: #[pin_project]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider allowing naming the projected type
1 participant