You can still do that today by consuming self like I mentioned above:
struct Queue<T> : ~Copyable {
var buf = UnmanagerBuffer<T>()
mutating func append(_ element: T) {
buf.append(element)
}
// contract: you must free the UnmanagedBuffer yourself
mutating func drain() -> UnmanagedBuffer<T> {
// avoid copying or retaining buf
let buffer = (consume self).buf
self = Queue<T>(UnmanagedBuffer<T>())
return buffer
}
deinit { buf.free() }
}
... but I get your larger point that just like it is nice to have the expressivity of not having to reconstruct self. For instance, consider if self's initializers have a bunch of arguments or if self only has non-trivial inits with business logic that you don't want to have to turn off when just trivially reconstructing self.