2 ms·
There is a swap operator built into the language, so that specific example would work (I think; I haven't checked the code). The escape hatch is to use the gen
by pcwalton 14y ago
There is a swap operator built into the language, so that specific example would work (I think; I haven't checked the code).
The escape hatch is to use the generic "Cell<T>" type in the standard library, which gives you dynamic behavior much like C++11 move semantics. The nice thing about the static analysis, though, is that the checks don't have to be performed at runtime if the compiler can prove that the value is always moved at the end of the block.