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 project_replace argument to be used without Replace #243

Merged
merged 1 commit into from
Jun 6, 2020

Conversation

taiki-e
Copy link
Owner

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

Currently, both Replace and project_replace = <name> arguments are required to name the return value of project_replace() method.

#[pin_project(Replace, project_replace = EnumProjOwn)]
enum Enum<T> {
    Variant(#[pin] T)
}

It is not ideal that we need to have both Replace and project_replace = <name> as project_replace = <name> implies that a project_replace method is generated.

This PR makes project_replace argument to use without Replace argument.

- #[pin_project(Replace, project_replace = EnumProjOwn)]
+ #[pin_project(project_replace = EnumProjOwn)]
  enum Enum<T> {
      Variant(#[pin] T)
  }

Also, makes project_replace argument an alias for Replace so that it can be used without a value.

#[pin_project(project_replace)]
enum Enum<T> {
    Variant(#[pin] T)
}

Related: rust-lang/futures-rs#2176 (comment) hyperium/hyper#2220 (comment)

@taiki-e taiki-e added C-enhancement Category: A new feature or an improvement for an existing one A-pin-projection Area: #[pin_project] relnotes labels Jun 6, 2020
Also, make `project_replace` argument an alias for `Replace` so that it
can be used without a value.
@taiki-e
Copy link
Owner Author

taiki-e commented Jun 6, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 6, 2020

Build succeeded:

@taiki-e
Copy link
Owner Author

taiki-e commented Jun 6, 2020

Also, the Replace argument will be deprecated in the future. (There is no way to generate a warning for an attribute argument, so just remove it in the next major version.)

@taiki-e taiki-e added A-project_replace Area: project_replace method and removed A-pin-projection Area: #[pin_project] labels Nov 17, 2020
@taiki-e taiki-e removed the C-enhancement Category: A new feature or an improvement for an existing one label Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-project_replace Area: project_replace method
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant