Skip to content

Generalize moves to allow moves out of any owned content #4384

Closed
@nikomatsakis

Description

@nikomatsakis

This program should be legal

struct Foo {
    v: ~[uint]
}

fn make_foo() -> Foo {
    Foo { v: ~[1, 2, 3] }
}

fn main() {
    let v = make_foo().v;
    for v.each |i| { io::println(fmt!("%u", *i)); }
}

But it yields:

/Users/nmatsakis/tmp/bar.rs:10:12: 10:24 error: moving out of immutable field
/Users/nmatsakis/tmp/bar.rs:10     let v = make_foo().v;
                                           ^~~~~~~~~~~~

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions