Is there movement on &move?

If I understand this correctly.. I think I may see another user case. Anonymous enums are hotly debated now. What it boiled down for me to (I'm using @eaglgenes101 's syntax) was a light-weight conversion:

let a: A = ...;
let ab: (A|B) = a;  // we're talking about something akin to Haskell's Either - an enum with 2 members with "names" (A|B)::0 and (A|B)::1; what has just happened could have been spelled let abc = (A|B)::0(a)
let bca : (B|C|A) = ab;  // we're talking about an enum with 3 members with "names" (A|B|C)::0, (A|B|C)::1 and (A|B|C)::2; what has just happened is a conversion - data has been copied from ab to bca and discriminant has been changed from 0 to 2 in the process
assert_eq!(bca, (B|C|A)::2(a));

So here we copied ab to bca changing discriminant in the process. But what if we wanted to change discriminant "in place"? Rust would need to forget the old variable and know to "reuse" same memory location as a new variable of a new type. Could &move be made useful here?

let a: A = ...;
let ab: (A|B) = (A|B)::0(a);
let bca : &move (B|C|A) = (&move ab) as &move (B|C|A); // no memory copied, just an in-place update of discriminant

@mcy did you mean something like this instead?

trait State {
  fn transition(&move self) -> &move dyn State;
}
1 Like