Skip to content

Naming arguments in Fn traits #2812

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

Open
elichai opened this issue Nov 11, 2019 · 6 comments
Open

Naming arguments in Fn traits #2812

elichai opened this issue Nov 11, 2019 · 6 comments
Assignees
Labels
A-function-pointers Proposals relating to function pointers. A-syntax Syntax related proposals & ideas T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@elichai
Copy link

elichai commented Nov 11, 2019

Hi,
Right now If there's a Fn* trait that has 2 parameters of the same type it's really easy to confuse which is which.
i.e.:

type Callback = FnMut(&[u8], &[u8]) -> Point;

If we could name the arguments it would become easier to read and harder to misuse.

type Callback = FnMut(x: &[u8], y: &[u8]) -> Point;
@hadronized
Copy link
Contributor

hadronized commented Nov 12, 2019

Here, x and y represent types. They’re type variables. Type variables should be PascalCase.

EDIT: Nah, they don’t. I was mistaken about what the author wanted to do. Sorry for the noise.

@Lokathor
Copy link
Contributor

No they're not?

@petrochenkov
Copy link
Contributor

Duplicate of #557 (but this issue has a better name and examples, not mentioning some pre-1.0 features).

@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the RFC. label Nov 12, 2019
@elichai
Copy link
Author

elichai commented Nov 12, 2019

Duplicate of #557 (but this issue has a better name and examples, not mentioning some pre-1.0 features).

yeah but sugar syntax for closures is a few levels above what i'm proposing.

@elichai elichai changed the title Naming params in Fn traits Naming arguments in Fn traits Nov 12, 2019
@hadronized
Copy link
Contributor

No they're not?

Yikes yeah, I was mistaken about what the OP wanted to do.

@petrochenkov petrochenkov self-assigned this Nov 12, 2019
@jonas-schievink jonas-schievink added A-function-pointers Proposals relating to function pointers. A-syntax Syntax related proposals & ideas labels Nov 17, 2019
@KarelHrkal
Copy link

The "duplicate" issue is marked as completed but it doesn't work. Playground link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-function-pointers Proposals relating to function pointers. A-syntax Syntax related proposals & ideas T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

7 participants