-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Merge init_pointee_move
and move_pointee_into
.
#3038
Comments
|
@bethebunny So |
_ = t.take_pointee()
t.init_pointee_move(s.take_pointee()) |
But the doctoring of If it calls the destructor of the old data, why can't we write t[] = s[]^ |
The really difference seems to be that struct S:
var data: Float64
fn __init__(inout self, data: Float64):
self.data = data
fn __copyinit__(inout self, other: S):
print(" copyinit", other.data)
self.data = other.data
fn __moveinit__(inout self, owned other: S):
print(" moveinit", other.data)
self.data = other.data
fn __del__(owned self):
print(" del", self.data)
fn move_pointee_into():
print("move_pointee_into:")
var v = S(10)
var t = UnsafePointer[S].alloc(1)
var s = UnsafePointer.address_of(v)
s.move_pointee_into(t)
print()
_ = v
fn init_pointee_move():
print("init_pointee_move:")
var v = S(20)
var t = UnsafePointer[S].alloc(1)
var s = UnsafePointer.address_of(v)
t.init_pointee_move(s.take_pointee())
print()
_ = v
fn main():
move_pointee_into()
print()
init_pointee_move() Result:
|
Review Mojo's priorities
What is your request?
As title.
What is your motivation for this change?
If I understand correctly, we don't need both.
Any other details?
N/A
The text was updated successfully, but these errors were encountered: