Here's the code I want to run:

pub enum EnumTwo {
    A(uint),
    B(uint)
}

fn get_map(env: &lt/mut EnumTwo) -> &lt/mut uint {
    match *env {
        A (ref mut map_a) => map_a,
        B (ref mut map_b) => map_b
    }
}


This fails with this error:

 jclements-09740:/tmp clements> rustc --test ./zap.rs
Running /usr/local/bin/rustc:
./zap.rs:13:11: 13:25 error: loan of enum content as mutable conflicts with 
prior loan
./zap.rs:13         B (ref mut map_b) => map_b
                       ^~~~~~~~~~~~~~
./zap.rs:12:11: 12:25 note: prior loan as mutable granted here
./zap.rs:12         A (ref mut map_a) => map_a,
                       ^~~~~~~~~~~~~~
error: aborting due to previous error


Patrick and I brainstormed on various moderately disgusting workarounds, but I 
couldn't find one that worked and returned a mutable borrowed pointer. I think 
I can see how to work around it by completely dismantling the abstraction that 
returns the mutable pointer. Am I missing anything ?

John

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to