Skip to content

Tuple's are not allowed as lvalues #10174

Closed
@adrientetar

Description

@adrientetar

Currently, this is unimplemented:

fn main() {
    let (x,y) = (1,2);
    (x,y) = (3,4);
}

The line (x,y) = (3,4); will trigger an error.

This is allowed in Python for example and can come in handy:

def fib_increment(n):
  a,b = 0,1
  for _ in range(n):
    a,b = b,a+b
  return a

Here, b allocated value depends on a and vice-versa. Not sure how this translates into lower-level code but at least here it spares an alloc and a line of code.

Also, being able to allocate a tuple from a function would come in handy, cf. #7507#issuecomment-23618416.

See #7507, #7508, #10123.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions