CEP-0051: Advanced Ownership Move-Out APIs¶
Draft
Draft proposal for moving values out of fields, arrays, slices, optionals, pointers, and containers. V1 move applies only to whole local bindings and by-value parameters.
Summary¶
Catalyst should eventually decide how explicit move-out and replacement APIs work for subobjects and containers.
V1 forbids or defers moving out of fields, array/slice elements, optional payloads, dereferenced pointers, globals, module bindings, and captured outer variables.
Example¶
Possible future shape:
fn take_name(user: *mut User) String {
return move user.name
}
fn pop_front(items: *mut std.collections.Vec(String)) ?String {
return items.take_at(0)
}
The proposal must decide how moved-out places are tracked, replaced, and cleaned up without breaking aggregate or container invariants.
Motivation¶
Moving out of subobjects is useful for containers and ownership-heavy code. It introduces partial initialization states, invariant preservation, cleanup ordering, and replacement requirements.
Proposed Direction¶
The proposal should cover:
- field move-out;
- array and slice element move-out;
- optional payload take APIs;
- pointer and container move-out;
- partial-move aggregate/container states;
- invariant-preserving replacement APIs.
V1 Compatibility¶
V1 uses whole-binding move plus explicit type/container APIs where accepted.