The following fails to compile:
struct Ref<T>: ~Copyable {
var value: T
init(_ value: T) { self.value = value }
}
func consumingMap<A>(
_ f: @escaping (inout A) -> Void
) -> (consuming Ref<A>) -> Ref<A> {
{ ref in
var newRef = ref
f(&newRef.value)
return newRef
}
}
with the error:
'ref' is borrowed and cannot be consumed.
Shouldn't consuming be inferred here, or am I missing something fundamental? (I feel like I've missed a huge amount of fundamental stuff on move-only types of late).