Will borrowing funcs in enums be possible in the future?
See the following error where bla() cannot be called twice.
struct A: ~Copyable {
func bla() {
print("A bla")
}
}
E>struct B: ~Copyable {
func bla() {
print("B bla")
}
}
E>enum E: ~Copyable {
case a(A)
case b(B)
consuming func bla() {
switch consume self {
case .a(let a):
a.bla()
case .b(let b):
b.bla()
}
}
}
struct Laber {
func laber() {
let e = E.a(A())
e.bla()
//e.bla() // bla.swift:27:21: error: 'e' consumed more than once
}
}
let laber = Laber()
laber.laber()
Without "consume self" the following error is generated:
bla.swift:16:24: error: noncopyable binding being pattern-matched must have the 'consume' operator applied