Feature request: Clone for Trigger
trevyn opened this issue · comments
It would be nice to have a cloneable Trigger that can cancel without needing to consume self.
I know how to achieve this, but thought I'd let you know that I think it would be a useful addition to the library. :)
What's your use-case for cloning a Trigger
? The way triggers are intended to be used is essentially as a drop guard, so when it goes out of scope, the stream is cancelled. If you could clone one, I'd worry about people cloning and not realizing that they are implicitly dropping one of the clones. If you specifically want multiple threads to collectively share a Trigger
, I'm kind of partial to Arc<Mutex<Option<Trigger>>>
— would that work for your use-case?