Cloning is convenient for AbortHandles given there can be more than one.
Solution
The proposed solution is similar to JoinHandle's abort_handle method:
impl Clone for AbortHandle {
/// Returns a cloned `AbortHandle` that can be used to remotely abort this task.
fn clone(&self) -> Self {
self.raw.ref_inc();
Self::new(self.raw)
}
}
This is a small change so that AbortHandle implements Clone.
Motivation
The the module level docs indicate
Cloning is convenient for
AbortHandle
s given there can be more than one.Solution
The proposed solution is similar to JoinHandle's
abort_handle
method: