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

Support omitting the variant name #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

traviscross
Copy link
Contributor

Let's say that we want to create a Send variant of a trait but we don't need a non-Send variant of that trait at all. We could of course just write that trait, but adding the Send bounds in all the right places could be annoying.

In this commit, we allow simply omitting the new variant name from the call to make. When called that way, we use the name from the item to emit only one variant with the bounds applied. We don't emit the original item.

For completeness and explicit disambiguation, we support prefixing the bounds with a colon (but giving no variant name). Similarly, for completeness, we support giving the same name as the trait item. In both of these cases, we just emit the one variant. Since these are for completeness, we don't advertise these syntaxes in the documentation.

That is, we now support:

  • make(NAME: BOUNDS)
  • make(NAME:)
  • make(:BOUNDS)
  • make(BOUNDS)

This resolves #18.

Let's add a test case using the full `NAME: BOUNDS` syntax to verify
that compilation works and that we get the bounds that we want.
Let's say that we want to create a `Send` variant of a trait but we
don't need a non-`Send` variant of that trait at all.  We could of
course just write that trait, but adding the `Send` bounds in all the
right places could be annoying.

In this commit, we allow simply omitting the new variant name from the
call to `make`.  When called that way, we use the name from the item
to emit only one variant with the bounds applied.  We don't emit the
original item.

For completeness and explicit disambiguation, we support prefixing the
bounds with a colon (but giving no variant name).  Similarly, for
completeness, we support giving the same name as the trait item.  In
both of these cases, we just emit the one variant.  Since these are
for completeness, we don't advertise these syntaxes in the
documentation.

That is, we now support:

- `make(NAME: BOUNDS)`
- `make(NAME:)`
- `make(:BOUNDS)`
- `make(BOUNDS)`

This resolves #18.
@tmandry
Copy link
Member

tmandry commented Feb 13, 2024

@traviscross These tests look great. Would you mind rebasing now that #27 is merged?

@Sytten
Copy link

Sytten commented Apr 29, 2024

Any movement on that?

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.

Provide a Shorthand for adding Send bounds
3 participants