struct Pair:
var x: Int
var y: Int
fn __init__(inout self, x: Int, y: Int):
print("Running init")
self.x = x
self.y = y
fn __moveinit__(inout self, owned existing: Self):
print("move init")
self.x = existing.x
self.y = existing.x
fn __copyinit__(inout self, existing: Self):
print("copy init")
self.x = existing.x
self.y = existing.y
fn copy(owned pair: Pair) -> Pair:
return pair
fn main():
let p = Pair(1, 2)
let moved = copy(p^)
let moved2 = moved^
struct Pair:
var x: Int
var y: Int
fn __init__(inout self, x: Int, y: Int):
print("Running init")
self.x = x
self.y = y
fn __moveinit__(inout self, owned existing: Self):
print("move init")
self.x = existing.x
self.y = existing.x
fn __copyinit__(inout self, existing: Self):
print("copy init")
self.x = existing.x
self.y = existing.y
fn copy(owned pair: Pair) -> Pair:
return pair
fn main():
let p = Pair(1, 2)
let moved = copy(p^)
let moved2 = moved^