-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Named impls #2251
Copy link
Copy link
Open
Labels
T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Metadata
Metadata
Assignees
Labels
T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Type
Fields
Give feedbackNo fields configured for issues without a type.
As of right now all impls are anonymous and public. I propose named impls and named public impls:
impl X as Y for Zfor a private implpub impl X as Y for Zfor a public implThis is similar to how traits currently work: you need to import them to use them.
With a non-pub impl, you can use it within your module. With a pub impl, you can use it outside your module. In any case, you need to explicitly import it with
use. You can also import them from an external crate, but it follows the same rules - only available where youusethem.Later we could also add
!pub impl Y for Zif we want crate-wide, anonymous impls. (Sadly, since they're already public by default, we can't haveimpl Y for Zandpub impl Y for Z, except maybe in Rust 2.0.)