I've been doing (more) playing around with non-copyable types, and have noticed that as?
, as!
and is
all are implicit consumes. For the as
operators that makes sense to me; less so for is
.
protocol Event: ~Copyable { }
struct MyEvent: Event { }
let event: any Event = MyEvent()
event as? MyEvent // bad
event as! MyEvent // bad
event is MyEvent // also bad
Two questions:
- Is there a sensible reason why
is
currently a consume? - It feels like there should be a way to do a scoped constrain of a non-copyable existential type without consuming it, but once again: is there some reason why that doesn't make sense?