swap
Signature
swap<T>(left: T, right: T): voidswap exchanges the values of two distinct mutable local bindings of the same type. It supports Copy values and string; exchanging strings transfers their owned allocations between the two bindings without copying their contents.
tyrus
import { swap } from "tyrus:memory";
function main(): void {
let left: i32 = 4;
let right: i32 = 9;
print(left); // 4
print(right); // 9
swap(left, right);
print(left); // 9
print(right); // 4
let first: string = "first";
let second: string = "second";
swap(first, second);
print(first); // second
print(second); // first
}