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

Cannot destructure the self argument #7613

Closed
brendanzab opened this issue Jul 6, 2013 · 3 comments
Closed

Cannot destructure the self argument #7613

brendanzab opened this issue Jul 6, 2013 · 3 comments
Labels
A-grammar Area: The grammar of Rust

Comments

@brendanzab
Copy link
Member

Currently we can destructure function arguments:

fn foo((x, y, z): (int, int, int)) -> int {
    x * y * z
}

assert_eq!(foo((1, 2, 3)), 6)

But there is no way of destructuring the self argument in methods. I don't know what kind of syntax this would involve, but the following sample shows a possibility:

trait Foo {
    fn foo(&self) -> int;
}

impl Foo for (int, int, int) {
    fn foo(&self @ &(x, y, z)) -> int {
        x * y * z
    }
}

assert_eq!((1i, 2i, 3i).foo(), 6);
@brson
Copy link
Contributor

brson commented Jul 22, 2013

Far future, por favor.

@huonw
Copy link
Member

huonw commented Nov 3, 2013

Triage, no change.

qpliu added a commit to qpliu/rust that referenced this issue Feb 28, 2014
@alexcrichton
Copy link
Member

Closing due to the rationale of this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust
Projects
None yet
Development

No branches or pull requests

4 participants