-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-grammarArea: The grammar of RustArea: The grammar of Rust
Description
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);
schneiderfelipe and JarvisCraft
Metadata
Metadata
Assignees
Labels
A-grammarArea: The grammar of RustArea: The grammar of Rust