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

DRY Self initialization syntax with tuple structs too? #42601

Closed
leonardo-m opened this issue Jun 12, 2017 · 2 comments
Closed

DRY Self initialization syntax with tuple structs too? #42601

leonardo-m opened this issue Jun 12, 2017 · 2 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@leonardo-m
Copy link

leonardo-m commented Jun 12, 2017

Do you want to accept the "Self(0, 0)" syntax too? I think it's more DRY:

struct VecA { x: u32, y: u32 }
impl VecA {
    fn new() -> Self {
        Self { x: 0, y: 0 } // OK
    }
}
struct VecB(u32, u32);
impl VecB {
    fn new() -> Self {
        Self(0, 0) // Error
    }
}
fn main() {}

The current error message is:

error[E0423]: expected function, found self type `Self`
  --> ...\test.rs:10:9
   |
10 |         Self(0, 0) // Error
   |         ^^^^ did you mean `Self { /* fields */ }`?
@leonardo-m
Copy link
Author

@Mark-Simulacrum Mark-Simulacrum added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 27, 2017
@Centril
Copy link
Contributor

Centril commented Nov 30, 2018

We are doing this now (#51994) so this can be closed.

@Centril Centril closed this as completed Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants