1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use TokenStream;
use quote;
use ;
/// Derive macro for the Handle trait.
///
/// This macro automatically implements the `Handle` trait for types that implement `Clone`.
/// The `Handle` trait provides a `handle()` method that is semantically equivalent to `clone()`,
/// but makes the intent clearer: creating another handle to the same underlying resource.
///
/// # Examples
///
/// ```ignore
/// use handle_trait::Handle;
///
/// #[derive(Clone, Handle)]
/// struct MyHandle {
/// inner: std::sync::Arc<i32>,
/// }
///
/// let h1 = MyHandle { inner: std::sync::Arc::new(42) };
/// let h2 = h1.handle();
/// ```
///
/// # Requirements
///
/// The type must implement `Clone`. If it doesn't, you'll get a compile error.