rust-lang / impl-trait-utils

Utilities for working with impl traits in Rust.
Apache License 2.0
89 stars 9 forks source link

Support omitting the variant name #30

Open traviscross opened 7 months ago

traviscross commented 7 months ago

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:

This resolves #18.

tmandry commented 7 months ago

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

Sytten commented 4 months ago

Any movement on that?